Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: j2mariashop on April 26, 2020, 04:10:40 PM

Title: M6 not updating Current Tool info.
Post by: j2mariashop on April 26, 2020, 04:10:40 PM
This topic has been beaten to death, but for the life of me I can't seem to fix this problem. On T5 M6 (where T on M6 line is tool to use), the tool number in the Current Tool Information box does not change. Actually, it doesn't change either if I switch T to be next tool. The problem persists whether I use upper or lower case M. Here's the standard script from the editor.

When I enter a G43 H5 command, the H offset changes correctly to Tool #5's, but the tool number is stuck at my touch off tool.

What's missing?

Joe



function m6()

   local inst = mc.mcGetInstance()
   local selectedtool = mc.mcToolGetSelected(inst)
   local currenttool = mc.mcToolGetCurrent(inst)
   
   if selectedtool == currenttool then
      mc.mcCntlSetLastError(inst, "Current tool == Selected tool so there is nothing to do")
   else
      --Remove this line if you would not like the Z axis to move
      --mc.mcCntlGcodeExecute(inst, "G90 G53 G0 Z0.0");--Move the Z axis all the way up
      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()
Title: Re: M6 not updating Current Tool info.
Post by: Graham Waterworth on April 26, 2020, 06:44:19 PM
Lathe or mill?
Title: Re: M6 not updating Current Tool info.
Post by: j2mariashop on April 26, 2020, 08:00:01 PM
Hi Graham,

This is for a mill.

Joe