This is my new code am I am going to try it out on my machine tomorrow. I have a looping section in there that seems to work, does anyone see any problems with running something like that. Also there is a section below that I need help with where I want to be able to manually jog the Z axis while in the M6 macro. Is there a way to do this then continue the macro.
function M6()
local inst = mc.mcGetInstance();
local selectedtool = mc.mcToolGetSelected(inst)
local currenttool = mc.mcToolGetCurrent(inst)
local hsig = mc.mcSignalGetHandle(inst, mc.ISIG_PROBE)
if selectedtool == currenttool then
mc.mcCntlSetLastError(inst, "ToolChange Activated But Not Required")
do return end
else
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0") --move z axis all the way up
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X0.464 Y-99.808") -- Move XY to above fixed touchplate location
local changetoo = mc.mcToolGetDesc(inst,selectedtool)
wx.wxMessageBox("Please change to tool "..selectedtool.." which is a "..changetoo.."")
toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, selectedtool)
if toollen ~= 0 then
local probestart = -6 + toollen
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart.."\n G91 G31 Z-.5 F25")
ProbeState = mc.mcSignalGetState(hsig)
repeat
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
wx.wxMessageBox("ERROR: Touch Probe was not detected reset tool")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart.."\n G91 G31 Z-.5 F25")
until(ProbeState ~= 0)
mc.mcAxisSetPos(inst, 2)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
mc.mcToolSetCurrent(inst, selectedtool)
mc.mcCntlSetLastError(inst, "ToolChange Finished")
else
wx.wxMessageBox("No tool length currently defined Lower Z to above touch plate, hit enter to start probe")
--need a way to lower Z manually here--???
mc.mcCntlGcodeExecuteWait(inst," G91 G31 Z-.5 F25")
ProbeState = mc.mcSignalGetState(hsig)
repeat
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
wx.wxMessageBox("ERROR: Touch Probe was not detected reset tool")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart.."\n G91 G31 Z-.5 F25")
until(ProbeState ~= 0)
mc.mcAxisSetPos(inst, 2)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
--wx.wxMessageBox("Please turn on spindle and click ok to continue") --can be removed if required
mc.mcToolSetCurrent(inst, selectedtool)
mc.mcCntlSetLastError(inst, "ToolChange Finished")end
end
mc.mcToolSetCurrent(inst, selectedtool)
end
if (mc.mcInEditor() == 1) then
M6()