Launching Code Editor From Toolbar

Technote 258
Date: 03/21
Product: All NC Applications
Version: All

Launching Code Editor From Toolbar

Using a SmartCAM macro, you can launch a text editor from within SmartCAM. This macro can be run directly or attached to a toolbar as a Macro Button. Historically, SmartCAM had partnered with Predator Software to provide an OEM version of their Predator CNC Editor. This editor could be launched from a toolbar, by using a macro.

You can download a copy of this macro, and related icon, using This Link.

This macro can be used as a basis for launching your own editor, or for launching a version of the Predator Editor that you have purchased. In either regard, it will likely need a small amount of editing to work properly on your computer.

To use the macro/icon download the ZIP file using the previously provided link. Extract the two files (peditor.mcl and peditor.ico) into a temporary folder. Copy the ICO (icon) file into your SmartCAM SHARED\ICON folder. The path changes slightly with each new major version of SmartCAM. For SmartCAM v2021, the path is:

\ProgramData\SmartCAM\SmartCAMv2021\SHARED\ICON

When new major version of SmartCAM are released, the SmartCAMv2021 part of the path changes. As you update your SmartCAM, try to remember to copy the ICO file over into the new ICON folder.

For the Macro, create a folder to store the macro. We suggest: \ProgramData\SmartCAM\Common\MCL\Editor. Copy the peditor.mcl macro into this folder. When running the macro, or creating a toolbar button, use this path.

Editing the Macro

The macro is very straight-forward. There is a variable that is the path to your editor. A variable that is the name of the current NC Code file. And finally, a variable that combines the other two into a command line that is run using the Windows Command Prompt shell.

//	Launches Predator Editor for SmartCAM with current Code file (if one)
//
//	CFile is current Code file
// EPath is fully qualified path to Predator Editor for SmartCAM
//	RLine is the concatinated string containing the command to run
STRING: #CFile
STRING: #EPath
STRING: #RLine
	
#EPath="C:\\Program Files (x86)\\Predator Software\\Editor 9.0\\PEditor.exe"
#CFile=CODFILE()
#RLine=STRTMP("%#EPath \"%#CFile\"")
	
//	Launch the editor, assumes in default location
SHELL[CMD_LN=#RLine, WA=0, DP=0]

The only editing that you need to complete is to modify the path contained in the #EPath variable to match the path to your editor. Do remember to use double-slashes (\\) for path separators.

After making the change to the path, run your SmartCAM application. Use Macro - Execute and browse to and run this macro. Make sure it works. If there are any errors, double-check the edits that you made.

Adding to Toolbar

Once you have verified that your macro works, you can add it to your toolbar. We recommend reviewing the Customizing SmartCAM topic for information on how best to approach this.

For current versions of SmartCAM, the overall steps are straight-forward.

  • Right-click on the toolbar that you want to modify.
  • Select Edit Toolbar from the pop-up menu.
  • In the Active Buttons list position the highlight where you want your button added. The button will be added directly below the highlight bar.
  • At a minimum, give the new button a Name, use the File Select button to browse to and select your macro file.
  • Enter peditor as the Icon Name - or whatever name you saved it as.
  • Use Accept to save the new button.

Use the ? icon on the Macro Button dialog to see the online help for this dialog. This way you can fill in all the fields.