Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: TTalma on March 06, 2022, 03:59:07 PM
-
My tool change scripts are writen in inches. When I have a file in MM It messes up the tool change script.
When the gcode file is using mm and switches the coordinates to mm, what do I need to add to my tool change script to switch to inches at start of script and switch back to mm at the end of the script?
-
It will take a little coding but this is basically what you need to do.
get current units
mcCntlGetUnitsCurrent
if G20 for inch
do tool change
if G21 for mm
set units to G20
do tool change
set units back to G21
-
It will take a little coding but this is basically what you need to do.
get current units
mcCntlGetUnitsCurrent
if G20 for inch
do tool change
if G21 for mm
set units to G20
do tool change
set units back to G21
This is great mcCntlGetUnitsCurrent was what I was looking for.
How is this used would I just do:
local units = rc.mcCntlGetUnitsCurrent(inst)
mc.mcCntlGcodeExecuteWait(inst, "G20")
...
do tool change stuff
...
if (units = "mm") then
mc.mcCntlGcodeExecuteWait(inst, "G21")
end
Is there any documentation of all the mc commands (mcCntlGcodeExecuteWait, mcCntlGetUnitsCurrent, etc.). I have not seen a document with them all listed. I would have expected them to be in the lua scripting manual found here: https://www.machsupport.com/wp-content/uploads/2014/05/Mach4%20Scripting%20Manual.pdf
-
here is where you can find all the mc calls
C:\Mach4Hobby\Docs\Mach4CoreAPI.chm
-
also this might be helpful if you have never done code in lua
https://www.machsupport.com/forum/index.php?topic=45397.0