81
Mach4 General Discussion / Load Gcode File not working in macro
« Last post by mediumSasuage on April 08, 2024, 09:11:05 AM »Hi All,
I am trying to make a macro that allows me to dynamically edit GCODE. To do this, I am going to edit the GCODE in python and save the file to a directory, then reload it into Mach4 using a macro. I have written a test macro for the load GCODE part:
When I run this macro within the ZeroBrane debugging tool, it appears to work fine. However, when I run it by calling the macro in gcode, it runs to end but does not actually load the GCODE. Anyone got any ideas why this may be/ any hints towards a solution?
Many thanks,
Dan
I am trying to make a macro that allows me to dynamically edit GCODE. To do this, I am going to edit the GCODE in python and save the file to a directory, then reload it into Mach4 using a macro. I have written a test macro for the load GCODE part:
Quote
function m313() --load gcode file
local inst = mc.mcGetInstance() -- get mach4 instance
mc.mcCntlCloseGCodeFile(inst)
wx.wxMessageBox('Closed GCODE')
local NextFileParen = "(C:\\Mach4Industrial\\Profiles\\CHAMP\\GCODE\\GCODEtoLoad.txt)"
--wx.wxMessageBox(NextFileParen)
local NextFile = string.gsub(NextFileParen, "[()%c%s]", "")
wx.wxMessageBox('next file\n'..NextFile)
wx.wxSleep(1) --gives Mach a second to do its thing
mc.mcCntlLoadGcodeFile(inst, NextFile)
wx.wxSleep(5) --gives Mach a second to do its thing
mc.mcCntlCycleStart(inst)
end
if (mc.mcInEditor() == 1) then
--dofile ("load_modules.mcs")
m313()
end
When I run this macro within the ZeroBrane debugging tool, it appears to work fine. However, when I run it by calling the macro in gcode, it runs to end but does not actually load the GCODE. Anyone got any ideas why this may be/ any hints towards a solution?
Many thanks,
Dan