Ok I got back at it today, here is my code that works to change from tool one to tool two.
I keep getting stuck as to how to use a tool change output variable that I can't build in a text string.
sure I can put a bunch of complex if statements for every time I use Tsig# but it will be so bulky
Tsig# needs to change based on
local SelectedTool = 2 ---mc.mcToolGetSelected(inst)
local CurrentTool = 1 --- mc.mcToolGetCurrent(inst)
I hard coded the 1 and 2 for debugging as you can see the tool changer is unfortunately more complex than would be optimal.
any help would be appreciated, thanks
local Tsig1 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT2)
local Tsig2 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT3)
local Tsig3 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT4)
local Tsig4 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT5)
----mc.mcSignalSetState(Tsig1out, 1)
------ Move to current tool change position ------
local GCode = ""
GCode = GCode .. "G00 G90 G53 Z0.0\n"
GCode = GCode .. string.format("G00 G90 G53 X%.4f Y%.4f\n", XPos1 + 1.3, YPos1)
GCode = GCode .. string.format("G00 G90 G53 Z%.4f\n", ZPos1 + 1.0)
GCode = GCode .. string.format("G01 G90 G53 Z%.4f F15.0\n", ZPos1)
mc.mcCntlGcodeExecuteWait(inst, GCode)
---Raise tool change holder #1
mc.mcSignalSetState(Tsig1, 1)
---Move x axis to place too in change holder
GCode = ""
GCode = GCode .. string.format("G00 G90 G53 X%.4f\n", XPos1)
mc.mcCntlGcodeExecuteWait(inst, GCode)
------ Release drawbar ------
local DrawBarOut = mc.OSIG_OUTPUT7
local hsig = mc.mcSignalGetHandle(inst, DrawBarOut)
mc.mcSignalSetState(hsig, 1)
---drop tool change holder #1
mc.mcSignalSetState(Tsig1, 0)
------ Move to next tool change position ------
GCode = ""
GCode = GCode .. string.format("G00 G90 G53 X%.4f Y%.4f\n", XPos2, YPos2)
mc.mcCntlGcodeExecuteWait(inst, GCode)
----Raise tool change holder #2
mc.mcSignalSetState(Tsig2, 1)
--- give it a bit of time
wx.wxSleep(1)
------ Clamp drawbar ------
mc.mcSignalSetState(hsig, 0)
---- move x axis to slide tool out of holder #2
GCode = ""
GCode = GCode .. string.format("G00 G90 G53 X%.4f\n", XPos1 + 1.3)
mc.mcCntlGcodeExecuteWait(inst, GCode)
----- lower tool change holder #2
mc.mcSignalSetState(Tsig2, 0)
------ Move Z to home position ------
mc.mcCntlGcodeExecuteWait(inst, "G00 G90 G53 Z0.0\n")
------ Reset state ------