Multi-Z File-Open Macro/Script by theminor
Version 0.6

This Plugin is designed to replace the standard File -> Open button in Mach. The plugin works by presenting the a File-Open dialog for the user to open a gcode file. Upon selecting a file, the user is prompted if he wants the file to be parsed (the prompt can be turned-off via the settings such that the parsing happens automatically without prompting). If the file is to be parsed,	the script will search for all toolchange operations which select a tool number set by the user in the settings (for example all "even" numbered tools, all "odd" numbered tools, or a specific tool number only). If an applicable toolchange is found, all "Z" axis moves in that toolchange section will be modified to axis movements on the A, B, or C Axis (set by the user) for the user's Secondary Z axis. A "G52" offset command  may also be inserted in these sections to accont for the offset (set by	user) of the Second Z axis from the First Z axis. Additional codes and options may also be inserted/set, such as M codes that turn the spindles on and off as appropriate in these sections. Once the file is parsed, the file is saved under a new file name with a suffix set by the user. The modified file is then opened in Mach, ready for execution as with any other gcode file. For additional help with this plugin, see the "tooltips" for each option in the configuration page of the plugin.

To install, copy the MultiZ.dll file to your Mach3\PlugIns directory. Load Mach and enable the plugin via the Config -> Config Plugins menu. Click OK and restart Mach. Upon restart, configure the plugin via the Plugin Control -> MultiZ menu.

The plugin requires the Microsoft .NET Framework Version 3.5 to be installed. This can be downloaded for free here: http://www.microsoft.com/en-us/download/details.aspx?id=22  --  If you get an error upon starting Mach, it is likely because you do not have the .NET 3.5 Framework installed.

Finally, to actually invoke the plugin, you will need to modify the button script of the button in Mach that you want to call the plugin to open the G-Code file. My preference is to change Mach's "Open G-Code" button, but any button can be used. The script should be modified with the following code:


Declare Function CallDLLFunc Lib "MultiZ" () As String
Dim file As String
file = CallDLLFunc()
If file <> "" Then
	LoadFile(file)
	' SetUserLabel (2, GetLoadedGCodeFileName())		' Uncomment this line (remove the single-quote at the beginning of the line) to Set the Use Label 2 to the file name that is loaded (useful if you use the 2010 Screenset or similar screenset)
End If  






This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. Please see:				
http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_US																		
This software is provided "as-is," without any express or implied warranty. In no event shall the author be held liable for any	
damages arising from the use of this software.