Oh, I wrote my own! Not what you wanted to hear but this is an example as a M-code. Its easy to make it into a button if you feel better doing it that way.
WARNING! My numbers are in metric. Millimeters… sorry
-- SNZ Probe Z Axis --
local FastFeed = 200 -- I apparently don't use some of these, doh!
local SlowFeed = 80
local BackOff = 3
local OffsetNum = 99
local ProbeSigTable = {
[31] = mc.ISIG_PROBE,
[31.0] = mc.ISIG_PROBE,
[31.1] = mc.ISIG_PROBE1,
[31.2] = mc.ISIG_PROBE2,
[31.3] = mc.ISIG_PROBE3
}
function checkProbe(state, code)
local inst = mc.mcGetInstance()
local check = true
local ProbeSignal = ProbeSigTable[code]
if (ProbeSignal == nil) then
mc.mcCntlSetLastError(inst, "ERROR: Invalid probing G code")
mc.mcCntlEStop(inst)
do return end
end
------------- Check Probe -------------
local hsig = mc.mcSignalGetHandle(inst, ProbeSignal)
local ProbeState = mc.mcSignalGetState(hsig)
local errmsg = "ERROR: No contact with probe"
if (state == 1) then
errmsg = "ERROR: Probe obstructed"
end
if (ProbeState == state) then
mc.mcCntlSetLastError(inst, errmsg)
mc.mcCntlEStop(inst)
check = false
end
return check
end
function setFixOffset(xval, yval, zval)
local inst = mc.mcGetInstance()
local FixOffset = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_14)
local Pval = mc.mcCntlGetPoundVar(inst, mc.SV_BUFP)
local FixNum, whole, frac
if (FixOffset ~= 54.1) then --G54 through G59
whole, frac = math.modf (FixOffset)
FixNum = (whole - 53)
PoundVarX = ((mc.SV_FIXTURES_START - mc.SV_FIXTURES_INC) + (FixNum * mc.SV_FIXTURES_INC))
else --G54.1 P1 through G54.1 P100
FixNum = (Pval + 6)
if (Pval > 0) and (Pval < 51) then -- G54.1 P1 through G54.1 P50
PoundVarX = ((mc.SV_FIXTURE_EXPAND - mc.SV_FIXTURES_INC) + (Pval * mc.SV_FIXTURES_INC))
elseif (Pval > 50) and (Pval < 101) then -- G54.1 P51 through G54.1 P100
PoundVarX = ((mc.SV_FIXTURE_EXPAND2 - mc.SV_FIXTURES_INC) + (Pval * mc.SV_FIXTURES_INC))
end
end
PoundVarY = PoundVarX + 1
PoundVarZ = PoundVarX + 2
if (xval ~= nil) then
mc.mcCntlSetPoundVar(inst, PoundVarX, xval)
end
if (yval ~= nil) then
mc.mcCntlSetPoundVar(inst, PoundVarY, yval)
end
if (zval ~= nil) then
mc.mcCntlSetPoundVar(inst, PoundVarZ, zval)
end
end
function m10103()
local inst = mc.mcGetInstance()
local rc = checkProbe(1, 31); if not rc then; do return end; end
------------- Get current machine state -------------
local CurFeed = mc.mcCntlGetPoundVar(inst, mc.SV_FEEDRATE)
local CurZOffset = mc.mcCntlGetPoundVar(inst, mc.SV_ORIGIN_OFFSET_Z)
local CurFeedMode = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_1)
local CurAbsMode = mc.mcCntlGetPoundVar(inst, mc.SV_MOD_GROUP_3)
local CurPosition = mc.mcAxisGetPos(inst, mc.Z_AXIS)
------------- Set Probe Offset, Relative Positioning -------------
mc.mcCntlGcodeExecuteWait(inst, string.format("G43 H%.0f", OffsetNum))
mc.mcCntlGcodeExecuteWait(inst, "G91")
------------- Fast Probe -------------
mc.mcCntlGcodeExecuteWait(inst, "G31 Z-50 F200")
rc = checkProbe(0, 31); if not rc then; do return end; end
------------- Back Off Probe -------------
mc.mcCntlGcodeExecuteWait(inst, "G01 Z3 F350")
------------- Slow Probe -------------
mc.mcCntlGcodeExecuteWait(inst, "G31 Z-10 F50")
rc = checkProbe(0, 31); if not rc then; do return end; end
------------- Get Position + Data -------------
local ZProbed = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_POS_Z)
local ZMachProbed = mc.mcCntlGetPoundVar(inst, mc.SV_PROBE_MACH_POS_Z)
local HeightOffset = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, OffsetNum)
local HeightOffsetW = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT_W, OffsetNum)
------------- Calculate Offset -------------
local NewWOVal = ZMachProbed - HeightOffset - HeightOffsetW
------------- Set Offset-------------
setFixOffset(nil, nil, NewWOVal)
------------- Safe Z-------------
--mc.mcCntlGcodeExecuteWait(inst, "G01 Z20 F350")
------------- Reset Machine State ------------------------------------
mc.mcCntlSetPoundVar(inst, mc.SV_FEEDRATE, CurFeed)
mc.mcCntlSetPoundVar(inst, mc.SV_MOD_GROUP_1, CurFeedMode)
mc.mcCntlSetPoundVar(inst, mc.SV_MOD_GROUP_3, CurAbsMode)
end
if (mc.mcInEditor() == 1) then
m10103()
end