Hello Guest it is April 26, 2024, 10:21:28 AM

Author Topic: changing coordinates systems during tool change  (Read 637 times)

0 Members and 1 Guest are viewing this topic.

changing coordinates systems during tool change
« 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?

Online Bill_O

*
  •  563 563
    • View Profile
Re: changing coordinates systems during tool change
« Reply #1 on: March 07, 2022, 11:09:48 AM »
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

Re: changing coordinates systems during tool change
« Reply #2 on: March 07, 2022, 11:49:45 AM »
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

Online Bill_O

*
  •  563 563
    • View Profile
Re: changing coordinates systems during tool change
« Reply #3 on: March 07, 2022, 01:27:49 PM »
here is where you can find all the mc calls
C:\Mach4Hobby\Docs\Mach4CoreAPI.chm

Online Bill_O

*
  •  563 563
    • View Profile
Re: changing coordinates systems during tool change
« Reply #4 on: March 07, 2022, 01:29:10 PM »
also this might be helpful if you have never done code in lua
https://www.machsupport.com/forum/index.php?topic=45397.0