Macros Part 3: Using Macros
Overview
Welcome back! We hope you are enjoying these posts and are learning things that will help you be more productive. In the last 2 posts, we went over creating macros. If you are interested in starting from scratch, you can check out this post first. In this post, we’ll show you the multitude of ways you can use to execute them now that you know how to create your own macros.
In this post, we’ll look at the following ways to run your macros:
- Macro menu
- HotKeys
- Command Line
- Buttons
Macro Menu
If you have created or been given macro files (.mcl files), and you are testing or just want to run them quickly with out extra setup, you can run your macros from the file menu by going to Macros > Execute. Once you have executed a macro, you will see that it is in the recently used macro list:
This is fine for testing or macros you don’t use much. We suggest using one of the automation methods below for macros you use more regularly. These will decrease your clicks and key strokes…increasing your productivity.
HotKeys
Depending on how you plan on needing a macro, one of the quickest ways of executing it will be to use HotKeys. HotKeys allow you to configure your SmartCAM product to use a simple set of key strokes which will run a given macro. Just like using Ctrl+C and Ctrl+V to Copy/Paste make it quicker to copy items, creating HotKeys for your macros gives you additional power at your fingertips!
Note: Unlike the information we have previously given you about storing your custom SmartCAM files, the changes made for HotKeys will automatically be retained during updates, so no need to store them in a special location.
For this exercise, we’ll use a set of files that have been pre-configured: A model (.jof and .pm5) and .mcl file. You can grab a copy of those here (make sure to put them somewhere you will remember. As suggested previously, you can put them in \ProgramData\SmartCAM\Common\ICON if you want to ensure they are not overwritten with your next SmartCAM update). If you want to try with your own files, all the better for you to continue to familiarize yourself with your SmartCAM product and these concepts.
Let’s get
started creating your first SmartCAM macro HotKey:
- Make sure your SmartCAM application is closed and not running.
- Before customizing an .ini file, make a backup copy of the original file with a different name. This allows you to recover the default .ini file if necessary.
- Generally you can find the application’s INI file in ProgramData\SmartCAM\SmartCAMv<version>\SCUSER. If you are having issues finding it, you can find its location by going to Help > About and it will be at the bottom of the About screen:
- The application’s .ini file will be named something like amill.ini (for Advanced Milling), pturn.ini (for Production Turning) etc.
2. Locate the [Hotkeys] section in the file. It will look something like this:
The [Hotkeys] section shows the various hotkey combinations supported by SmartCAM and the default HotKeys. Take note of these also for other uses while programming in SmartCAM.
You will notice that there are some items with a leading semicolon. A semicolon comments out a line if it’s not being used. If the key or key combination you want to use is commented out, remove the leading semicolon. This will uncomment the line and make the HotKey usable.
3. Locate the key or key combination you want to assign to your macro. You will want to ensure you use an unused HotKey if you want to maintain the default hotkeys for SmartCAM. For this example, we’ll be using Ctrl+F11 with the macro desired.
4. Assign the macro to the key/key combination using the following syntax:
macro "path\filename.ext".
· Ours looks like this:
- Notice that we didn’t just call the macro file. First we had to tell the HotKey that the thing it would be used for is a “macro”.
- Also to note is that because Ctrl+F11 was not being used, we removed the semicolon so that HotKey is no longer commented out.
5. Save the .ini file.
6. Open the SmartCAM product you are using and open a model you can test with. Again, you can use our arc example by downloading that here if you like.
7. Enable
the group selection tool and drag to select
both the arcs (or any set of elements you’d like).
8. Now press the Ctrl+F11 key combination and you should get a popup message telling you how many elements are in the grouping you selected.
Easy, right?! Using HotKeys to run those macros you use most often will speed up your delivery times considerably.
Command Line
Another option to run a macro is via Command Line. This allows you to use Microsoft’s native CMD to open your product, open a specified model and have it run a macro automatically. Using macros via Command Line is only available when starting your SmartCAM product.
For this exercise, we are going to use Command Line to open the product, a new model with some arcs and holes (with some elements hidden), and ensure all elements are showing when the model opens. You are welcome to use one of your own models and macros.
This is a simple task but, as always, you can use these concepts to build out more complex automation.
We'll start by doing a simple command line:
1. Download the arcs-holes model here and save it somewhere you know where it is. If you are using your own file, just make sure you know where it is and its exact name. You will also want to make sure some elements are hidden when you save it so you can see the Command Line in action.
2. Create a .mcl file with your favorite text editor and name it ShowAll.mcl.
This macro will have a single line in it:
SHOW_HIDDEN[]
So add that to your .mcl file and Save it.
3. Open the Windows Command Prompt by going to the Windows Start menu and typing in “CMD”. Select the Command Prompt application.
4. Type in the command you want to run. Here is the line simplified: Location\Product -f”Location\File” -m”Location\Macro File”
Here is the line we used:
"C:\Program Files\SmartCAM\SmartCAMv2026\SYSTEM\amill.exe" -f"C:\test\arcs-holes.pm5" -m"C:\test\ShowAll.mcl"
It is best practice to put quotes around file locations. They aren’t always needed but better to have them and not need then to need them and not have them.
- In our example, the product file and location are the default location for, in this case, SmartCAM Advanced Milling v2026. Yours will be different if you are using a different product and/or version, or have a custom install.
- The command -f tells Windows which file to open.
- The command -m tells it which macro to run.
- You will notice that for simplicity, we put our files in a “Test” folder directly on C:\. While you can do this for testing, it’s not great for regular use…it just makes typing or pasting easier. It also helps ensure SmartCAM has access to the file. Be careful not to use network locations if you can avoid it.
6. Now that you have that working, go ahead and close your SmartCAM product but don’t save the file. Let it revert to where some of the elements are hidden.
Now let’s create a batch file.
By executing a .bat file, it should do the same as running the Command Line directly from a Command Prompt. By having it in a .bat file, you can make edits easily and you don't have to type in everything every time.
1. Create a new file in a text editor like Notepad.
2. Give it a name meaningful to you and the extension .bat. Add in the line of code that tells Windows which product and file to open and the macro to run. Here is what ours looked like:
Note: If you close your .bat file, you can’t just double click on it if you need to edit it. If you double click it, it will run the .bat file. If you closed it and need to edit it, right click on the file and go to Open With > Notepad.
3. To test you .bat file, simply double click on it.
Like running the Command Line above, running the .bat file should open your model and show all elements.
While Command Line is only usable when starting your SmartCAM product, here is one more way to automate macros once you are in your SmartCAM product:
Buttons
Because this is one of the quicker ways to use macros, and so many customers use this method, we have a series of blog posts about Customizing Toolbars (one of the uses being to add buttons that run macros). For details on using buttons for macros, please start here. For this post, however, here is an overview:
- You can create a button for any macro you have.
- These buttons can be customized so that they use text and graphics so you can identify them quickly.
- All Toolbars are customizable AND you can create your own Toolbar. By creating your own Toolbar, you can add all your favorite tools and your custom buttons for easy access to those things you use most often. You can also have your custom Toolbar always floating in your workspace for easy access. Here is an example:
Again, if you would like detailed instructions on this, please go here.
As always, we hope you have learned something that you can use to help you be more productive with SmartCAM!
If you have any questions, please let us know in the comments and please do fill out this quick survey to help us continue to create posts you find useful and interesting.
No comments:
Post a Comment