Hi,
one of the Goto ways of diagnosing mal-conformed scripts is to use either the Status Bar or a wxMessageBox as output at various places through the script.
For example:
Code:
mc.mcCntlSetLastError(inst, "Probing in Progress!")
mc.mcCntlGcodeExecuteWait(inst, " G91 G31 Z-5. F6.5")--probe the new tool
local probedz = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z) -- Z Probe position in Machine coords
wx.wxMessagebox("probedz= ",toString(probedz))
mc.mcCntlGcodeExecute(inst, string.format('G ' .. posmode))--return to pre macro mode G90, or G91
mc.mcCntlGcodeExecuteWait(inst, "G00 G53 Z-1.5 ")--Retract
local GageBlockHeight=.394 --Gage Block Height
local NewOffset = probedz-GageBlockHeight
wx.wxMessagebox("NewOffset= ",toString(NewOffset))
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")
With these two wxMessagbox(es) you should be able to confirm the raw probed height and then compare that to the NewOffset which should be (probedz-GagaBlockHeight)
Craig