Machsupport Forum

Mach Discussion => Mach4 General Discussion => Mach4 Videos => Topic started by: DazTheGas on October 06, 2015, 06:09:49 PM

Title: Creating an M6 Toolchange in Mach4 (Part 1)
Post by: DazTheGas on October 06, 2015, 06:09:49 PM
This is part 1 of creating my own M6 Toolchange in mach4

https://youtu.be/m1eMEec0N-E (https://youtu.be/m1eMEec0N-E)

The Code so far in this part

Code: [Select]
function M6()
    local inst = mc.mcGetInstance();
    local selectedtool = mc.mcToolGetSelected(inst)
    local currenttool = mc.mcToolGetCurrent(inst)

    if selectedtool == currenttool then
    return
    mc.mcCntlSetLastError(inst, "ToolChange Activated but Not Required")
    else
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0")
    mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 X260 Y50")
    local changetoo = mc.mcToolGetDesc(inst,selectedtool)
    wx.wxMessageBox("Please change to tool number "..selectedtool.." "..changetoo.." and press ok to continue")

    wx.wxMessageBox('Toolchange finished')
    end

end

if (mc.mcInEditor() == 1) then
    M6()
end


DazTheGas
Title: Re: Creating an M6 Toolchange in Mach4 (Part 1)
Post by: dude1 on October 07, 2015, 03:24:49 AM
 mc.mcCntlGcodeExecuteWait(inst,"G90 G53 G0 Z0.0 \n X260 \n Y50 ") can work the same as both Gcode lines, \n = wait to finished probably know that already
Title: Re: Creating an M6 Toolchange in Mach4 (Part 1)
Post by: DazTheGas on October 07, 2015, 03:37:37 AM
Yes that is correct and such lines can be joined after function is finished, but during a tutorial it makes sense to show in separate steps so others can follow easier what the function is doing.

BTW \n = newline

DazTheGas
Title: Re: Creating an M6 Toolchange in Mach4 (Part 1)
Post by: dude1 on October 07, 2015, 03:42:29 AM
cool more info on \n for other`s
http://www.lua.org/pil/2.4.html