Hello Guest it is March 28, 2024, 01:44:37 PM

Author Topic: Plugin Access to GCode Window  (Read 7915 times)

0 Members and 1 Guest are viewing this topic.

Plugin Access to GCode Window
« on: December 26, 2011, 06:10:11 AM »
Hi, I am new to writing plugins for Mach3 but I have written a few simple wizards. I am looking to move some of my wizards to plugins because debugging in MachScreen is difficult for large wizards. Most of my wizards simple write to the teach file when a user clicks the "Post GCode" button. My first attempt at using the OpenTeachFile() and CloseTeachFile() methods with the VS2008 Plugin wizard failed with unknown function calls. So what I need to know is:

1. Is there a way to write text (gcode) directly to the code window in the main Mach3 screen?
2. Are there functions that can be used to write and load the teach file from a C++ plugin?
3. I have been able to run my gcode right from my plugin but this gives no visual indication of the code execution... If there is no way to load a file into Mach from a plugin like you can from a wizard, then is my best approach simply add a textarea code window to my plugin?

Thanks for your input.

P.S. I have searched for similar post but found nothing and I do apologies if this has been answered before and I simply did not locate the post, or if I have posted this to the wrong area.

Re: Plugin Access to GCode Window
« Reply #1 on: January 12, 2012, 12:43:39 PM »
Hi,

I don't think there is a way to write code to the codebuffer of Mach3.

But you can write to a teachfile as you can do it with your wizards.
Generally spoken, you can do everything in a plugin what you do in a script, and something more  ;)
So I have moved some bigger VBA-Skripts to a plugin just by a VBA to C converter and a little handwork.

Code: [Select]

  scripter.OpenTeachFile("teachtest.nc");

  // some sample code for the teachfile
  scripter.Code("G0X100Y100");
  scripter.Code("G1Z-10");
  scripter.Code("G1Z0");
  scripter.Code("G0X0Y0");

  // finish and load it
  scripter.CloseTeachFile();
  scripter.LoadTeachFile();

just tested this code, but I'm not working with the VS2008 wizard, I'm with VS 2003

regards,

Steffen
Re: Plugin Access to GCode Window
« Reply #2 on: January 12, 2012, 01:10:40 PM »
Thanks,

That is exactly what I needed since I can't go right to the buffer. What VB to C converter are you using?
Re: Plugin Access to GCode Window
« Reply #3 on: January 12, 2012, 02:01:17 PM »
I used BCX, this does the most stuff.

String concatenation had to be changed from VBA to C:

Quote
Code "G90G53G0Z" & PositionZ
to
Quote
Code(Format("G90G53G0Z%f", PositionZ));

then indent with my favorite settings:
Quote
indent -ts2 -npsl -bad -bap -bl -bli0 -di10 -bc -lp -l200 <filename>

Then of course the changes to better coding with the methods of C++  ;D

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Plugin Access to GCode Window
« Reply #4 on: January 18, 2012, 06:55:50 PM »
not trying to argue,

but you can load and run g-code directly from within the plugin, as well as run VB scripts from within a plugin as well (i.e. Mach MAD does this).

Having said the above, though it is MUCH simple to just make "Macros" in VB then run those from within your plugin. You can have your Macros do those things
you want, and then the plugin call them.

scott
fun times
Re: Plugin Access to GCode Window
« Reply #5 on: January 19, 2012, 10:06:58 AM »
You're right, but he wants to see the G-Code in the gcode window and the path preview.

This is only possible with loaded G-Code files, as far as I know.

Steffen

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Plugin Access to GCode Window
« Reply #6 on: January 19, 2012, 08:01:50 PM »
I understand, but what I was saying was you can do just that.......

scott
fun times
Re: Plugin Access to GCode Window
« Reply #7 on: January 19, 2012, 09:26:02 PM »
Also correct, you can do that.

But I have no idea, why you should use parts of your code back to this Basic-side, when you know how to code in Plugins.
Maybe to have user-changeable parts, but when there is no need for this, it is strange to go back into vba.

I also do not see, where VBA is simpler for people who already have plugins.

Steffen

Offline poppabear

*
  • *
  •  2,235 2,235
  • Briceville, TN, USA
    • View Profile
Re: Plugin Access to GCode Window
« Reply #8 on: January 20, 2012, 08:11:53 PM »
Steffen,

   Yes it is a mystery why he would want to do it that way.........

Scott
fun times
Re: Plugin Access to GCode Window
« Reply #9 on: January 21, 2012, 10:15:38 AM »
Huh? I do not understand?

He didn't want anything like that...

Steffen