Hello Guest it is April 19, 2024, 09:57:01 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - theminor

Pages: 1
1
Mach SDK plugin questions and answers. / Plugin or Script to Modify Gcode
« on: October 17, 2012, 10:15:47 AM »
I'm trying to determine the best way to handle this. I'm looking to write a fairly simple plugin (or macro script?) that makes modifications to a gcode file whenever it is opened in Mach. Basically the plugin/script would, after a gcode file is opened, parse the gcode file to make certain modifications to the code and then save the changes to the gcode window for execution.

The purpose for wanting to do this is that I've added a second Z axis and second router to my machine. I assigned the second Z axis as the "A" axis in Mach. The second Z axis is at a known offset on the X-Y plane, so I want Mach to parse all loaded gcode files and search for all toolchanges which ask for Tool #2. It will then change all "Z" axis moves to "A" axis moves within that section of Gcode. It will also insert the proper offset code, etc.

I realize I could accomplish the same thing with the swapaxis() command via a macro, but this seems dangerous in that the change can be permanent to the pin designations if mach exits with swapaxis() still active.

I also realize I could simple modify the post-processor in my CAM package to handle all this, but I want a more universal solution.

One way that I might accomplish this would be to create a wizard that brings up a File-Open dialog and thereafter parsed the gcode, saving the result to the "teach file" and posting the gcode. This might work (I think) but I'd prefer to use Mach's actual gcode load routine if possible. It would also be nice if I could save the result to an actual gcode file prior to posting to the gcode window. I'm not sure if any of the above is possible, however.

Ideally, this would be a plugin (I think) with its own plugin options dialog, but I'm having a hard time finding the documentation needed to execute these types of functions. I've watched the tutorial videos and done a fair bit of searching but I can't find information on a plugin's ability to access a loaded gcode file and to modify it.

I would welcome any comment/advice/direction! Thanks in advance.

Pages: 1