maybe I asked this question wrong or something as I got no response so let me try it a different way.
I'm running Mach4 version: 4.2.0.4612 build: 4612 , for the tool change m6 I am using this code:
function m6()
local inst = mc.mcGetInstance()
----------------------------------------------------------------------------------
--change lines here to either auto rapid, or manually jog to a tool change position
----------------------------------------------------------------------------------
--Manual Lines. Uncomment line below to allow you to manually jog to a tool change position.
--local MyChoice = wx.wxMessageBox("Click OK, \nThen Jog to A Safe Tool Change Position,\nInsert New tool,\nThen Click Cycle Start.","Click OK to continue" , 16)
---------------------------------------------------------------------------------
--Auto Lines. Uncomment both lines below (and comment out local MyChoice line above) to automatically move to tool change position.
--Edit to include the machine coordinate values of that tool change position.
--AUTO LINES
--mc.mcCntlGcodeExecuteWait(inst, "G53 G0 Z0\nG53 G0 X14.7148 Y-22.713")--Move the Z to Home.Then to the X, Y Coords for our touch pad.
--mc.mcCntlSetLastError(inst, 'Now in Tool Change Position. Hit Cycle Start!')
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local posmode = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_3) --get the current mode so we can return to it when macro ends
local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)
if selectedtool == currenttool then
mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do")
else
mc.mcCntlToolChangeManual(inst, true);
mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedtool) .. " Previous Tool == " .. tostring(currenttool))
mc.mcToolSetCurrent(inst, selectedtool)
local MyChoice = wx.wxMessageBox("Click Ok to Begin Probing the New Tool","Click OK to continue" , 16)
mc.mcCntlSetLastError(inst, "Probing in Progress!")
mc.mcCntlGcodeExecuteWait(inst, " G91 G31 Z-5. F5.")--probe the new tool
local probedz = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z) -- Z Probe position in Machine coords
mc.mcCntlGcodeExecute(inst, string.format('G ' .. posmode))--return to pre macro mode G90, or G91
mc.mcCntlGcodeExecuteWait(inst, "G00 G53 Z0 ")--Retract
local NewOffset = probedz
mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, selectedtool, NewOffset)
mc.mcCntlSetLastError(inst, string.format("Auto tool setting complete, Offset = %.4f", NewOffset))
wx.wxMessageBox("Toolchange Complete.\nTLO Set")
end
end
if (mc.mcInEditor() == 1) then
m6()
end
I'm using sprutcam 14
this is the first part of the code and the first tool change and it works correctly:
(Tool) (1) (Diametr)(0.875) (.875) (Operation) (Rotary Roughing 875)
(Tool) (2) (Diametr)(0.5) (0.5) (Operation) (Rotary finishing)
N10 G90 G64 G50 G54 G80 G17 G40 G49
N20 G20 (Inch)
(Rotary Roughing 875)
N30 M998
N40 T1 G43 H1 M6
(.875)
N50 S18000 M3 M8
N60 G0 G94 X-47.4688 Z5.761 A-124.965
N70 G1 Z4.011 F300
N80 Z4.0122 A-129.811 F884.18
N90 Z4.0082 A-132.406 F1651.35
this runs fine untill it gets to the finishing bit this is the code, after the tool change it goes back to the beginning
of the roughout code. to be clear it asks for you to hit ok , then the spindle starts and the code rewinds all the way back to the begining of the roughout code after the roughout tool change. any help would be greatly appreciated, I'm sure its right in front of me but I'm new to Mach 4
N341070 Z5.092 A162.095 F171.43
N341080 M5 M9
(Rotary finishing)
N341090 M998
N341100 T2 G43 H2 M6
(0.5)
N341110 S18000 M3
N341120 G0 X-47.2 Z4.3506 A0.
N341130 Z2.0054
N341140 G1 Z1.0054 F300
N341150 X-47.0802 Z0.8602 F300
N341160 X-47.0602 Z0.8291 F300