Within a UserGUIModule.mcs file, near the bottom you will find a section called UserGUIModule.CreateUserCommands(). You can add the following to into this function. This will create a User command which can then be added to a function button on widget panel. The mcTouchOff.lua module can then be called directly from a button on screen. The version in this thread has heights for EACH probe allowing the use of multiple types of Z probes. For example, a simple XYZ plate, a XHC wireless probe or a 3d touch probe. All of these would need to be wired to a separate probe input. There are four G31, G31.1, G31.2, G31.3
function UserGUIModule.mcTouchOff()
if (Tframe == nil) then
-- TouchOff module
package.loaded.mcTouchOff = nil
mcTouchOff = require "mcTouchOff"
Tframe = mcTouchOff.Dialog()
else
Tframe:Show()
Tframe:Raise()
end
end
function UserGUIModule.CreateUserCommands()
-----------------------------------------------------------------------------------
--- Open Touch Off Dialog
-----------------------------------------------------------------------------------
w.CreateCommandActionOption("mcTouchOff", function(from_opr_panel) UserGUIModule.mcTouchOff() end)
w.CreateSimpleCommand("mcTouchOff")
return true, true, w.FunctionCompleted()
end
then you right click on a button, configure widget and select mcTouchOff from the dropdown. Now when you press the button, it will popup the mcTouchOff wizard and you can run any of the routines. In particular, I needed the two probes with differant heights. The MachPro supplied wizard, does not take into account the height of the probe when doing a Z height probe
Thanks to Paul Stephen for the insight and help with this and Claude AI for the modifications to the original code from Mach4. I do know of one bug in the code but it's not a game changer. When you initially set a height for a probe, the display does not reflect the new height. Only after selecting a new probe and then going back will it display the new height.