Hello,
I created a new DRO on the screen, input it and am trying to use it in the M6 for tool change.
The names of the DRO on the screen are Xpos1, Ypos1, PlateThicknes.
And i created variables like below in M6 script.
local xstart= scr.GetProperty("Xpos1", "Value")
local ystart = scr.GetProperty("Ypos1", "Value")
local StrikePlateThickness= scr.GetProperty("PlateThickness", "Value")
But T2 M6(Tool change G-code) is skipped when simulate.
If the above three lines are deleted, they are executed without skipping.
I do not know what is the problem.
** I referred to the data of DazTheGas.
Thanks, DazTheGas.
function m6()
local inst = mc.mcGetInstance()
local ProbeSignal = mc.ISIG_DIGITIZE
local MaxToolNum = 6 ---- MaxToolNum = 6
local ToolUp = -5
local SelectedTool = mc.mcToolGetSelected(inst)
local CurrentTool = mc.mcToolGetCurrent(inst)
local xstart = scr.GetProperty("Xpos1", "Value")
local ystart = scr.GetProperty("Ypos1", "Value")
local StrikePlateThickness = scr.GetProperty("PlateThickness", "Value")
------------- Get touch off parameters -------------
if selectedtool == currenttool then
return
mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do")
else
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X14 Y30")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart)
mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-15 F25")
local toolz = mc.mcAxisGetPos(inst,2)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
local changetoo = mc.mcToolGetDesc(inst,selectedtool)
wx.wxMessageBox("Please change to tool number "..selectedtool.." "..changetoo.." and press ok to continue")
currenttool = selectedtool
toollen = mc.mcToolGetData(inst, mc.MTOOL_MILL_HEIGHT, currenttool)
probestart = guesslen + toollen
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X14 Y30")
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z"..probestart)
mc.mcCntlGcodeExecuteWait(inst, "G91 G31 Z-15 F25")
mc.mcAxisSetPos(inst, 2 , toolz)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..xstart.." Y"..ystart)
mc.mcToolSetCurrent(inst, selectedtool)
wx.wxMessageBox('Toolchange finished')
mc.mcAxisSetPos(inst, 2 , toolz)
mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
mc.mcCntlGcodeExecuteWait(inst,"G90 G0 X"..xstart.." Y"..ystart)
mc.mcToolSetCurrent(inst, selectedtool)
wx.wxMessageBox('Toolchange finished')
mc.mcCntlToolChangeManual(inst, true);
mc.mcCntlSetLastError(inst, "Current tool == " .. tostring(selectedtool) .. " Previous Tool == " .. tostring(currenttool))
mc.mcToolSetCurrent(inst, selectedtool)
end
end
if (mc.mcInEditor() == 1) then
M6()
end