i started out trying to get the register. by looking in the manual and came up with this
local hreg = mc.mcRegGetHandle(inst, string.format("droGageBlockT"))
i belive this is the point is was giving me errors about it returning a string instead of a value so i tried somthing else.
scr.GetProperty("droGageBlockT", "Value") is how i finally was able to get a value. but this line will cause my code to not execute. As well as the math line below. i commented it out as well. if i leave those 2 lines out the code runs fine. but if i uncomment them, all the values come back correctly in the script editor but if i try and do a m6 toolchange it wont do anything at all.
function m6()
local inst = mc.mcGetInstance()
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)
local xstart = mc.mcAxisGetPos(inst, 0) --X Axis--
local ystart = mc.mcAxisGetPos(inst, 1) --Y Axis--
*local tsoffset = scr.GetProperty("droGageBlockT", "Value") --Get Value of tool setting gage block--height offset of tool setter and material top--
if selectedtool == currenttool then
mc.mcCntlSetLastError(inst, "No Tool Changed Required")
else
mc.mcCntlGcodeExecuteWait(inst, "G53 G0 Z-0.2\nG53 G0 X10.0 Y-46.0857")--Move the Z to Home.Then to the X, Y Coords for our tool change.
mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedtool) .. " Previous Tool == " .. tostring(currenttool)) --Specify which tools changed--
wx.wxMessageBox("Remove Dust Boot and Change Tool \nThen Press Ok")
mc.mcCntlGcodeExecuteWait(inst, "G53 G0 X0.6831 ") --Move to Tool Setter position--
local MyChoice = wx.wxMessageBox("Click Ok to Begin Probing the New Tool","Click OK to continue")
mc.mcToolSetCurrent(inst, selectedtool) --change selected tool to current
mc.mcCntlSetLastError(inst, "Probing in Progress!")
mc.mcCntlGcodeExecuteWait(inst, " G91 G31 Z-5. F10.")--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 Z-0.2")--Retract
local NewOffset = probedz --math.abs(probedz - tsoffset)--
mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, selectedtool, NewOffset)
mc.mcCntlSetLastError(inst, string.format("Auto tool setting complete, Offset = %.4f", NewOffset))
mc.mcCntlGcodeExecuteWait(inst,"G53 G0 X10")
wx.wxMessageBox("Toolchange Complete.\nReplace dust boot")
mc.mcCntlGcodeExecuteWait(inst, "G90 G0 X"..xstart.."Y"..ystart)
end
end
if (mc.mcInEditor() == 1) then
m6()
end