Moving ahead in our year of efficiency, we need to find ways to do more in less time while not reducing the quality of the end product. With AutoCAD being a major tool in our daily workflow, it is a prime target for optimization. In a recent article I wrote (not yet published) I used the following definition for efficiency when working with AutoCAD:
With this concept in mind, the first post in our two-part series is going to be about creating and using macros in AutoCAD and how they can speed up your work Tenfold. Macros can be very powerful and can be used to perform a variety of tasks, including automating command prompts, controlling CADD standards and even automating CADD management steps. I will cover some examples of each in this series.
No matter what field you’re in, after a while you find yourself doing the same steps over and over again. Some are on a weekly basis, some daily and some even hourly or shorter. Anytime we repeat a step, task, process, or command there are certain questions or prompts that need to be answered like; Yes, No or Return. We are also prompted to pick points, set layers, set styles and choose rotations. These are things that are repeated so much we answer them without much thought, all while caring on a conversation with our cube mate and planning the next two commands and the answers to their associated prompts. Although we can practically enter these choices in our sleep, my question is why are we?
Well I for one am not going to do it anymore and neither are you. Something has to automate this process so we can use our brain for thinking about more important things. “Macros” to the rescue. I do not recall when macros came in to play in AutoCAD, but I know I have been customizing and using them since AutoCAD version 9. No matter your experience level, macros are one of the easiest customization tools you can do to increase your productivity and you are only limited by your creativity. In the current company I work with, 95% of our work is accomplished through Toolbar Macros, including customized replacements of standard AutoCAD commands.
For this exercise we are going to need a toolbar to place our custom macros on, so we need to take a quick look at the CUI editor (I miss the old MNU text editor days). I am currently working in 2013, but some variation of the CUI editor has been around since version 2006. If you’re a visual person, I created a PDF of version of this article with screen shots here.
For a more in-depth look at the CUI editor, check out Melinda Heavrin’s article from AUGI World on AUGI.com labeled:
Macro Mania – Toolbar Creation:
To keep our customized work separate from the main menu (highly recommended) and make it available to everyone in the company, you are going to want to have this in your central customization file on the company server. Don’t have one yet – let’s get one started (If you already have one, skip past this section):
Central Customization Menu File Creation:
Select Save and browse to a shared folder on your server that everyone has access to. This should be in your central CADD standards drive (preferred) or CADD standards folder. If you do not have one, we have some more work to do, but we will have to address that another day. Email me if you need some help on that.
Assuming you or someone else set this up already, under your “Menus” directory save the file with a logical name (other than custom). Precede it with the same thing you preceded your other standards with… I mean if you have them… If you don’t have this type of setup, let’s use your initials to get the ball rolling, we can rename it later once your actual standards are in place. Let’s assume your initials are “CTS” for Carol or Conrad Smith. Save the file as CTS-Custom. Yes I used “custom”, but the trick is to use a prefix that makes it unique. You can call it CTS-Master, or CTS-Standard or whatever you like, but make sure it has the prefix. You will understand as we talk more about this concept in future posts or you can email me if you need to know now.
Now that you have a new customization file, let’s add a toolbar. Right click on the word “Toolbar” in the right hand pane and select “New Toolbar”. Name it “Efficiency” (no Quotes). Now select “OK” at the bottom of the screen and you will be back in AutoCAD. Now type “MENULOAD” (no quotes). Select Browse and browse to the folder where you saved the CTS-Custom menu, which will be called CTS-Custom.cuix. Highlight the file and select “Load” and then “Close”. When you are back at the AutoCAD screen, you will see an empty floating toolbar, and if you roll over it with your mouse it will be called “Efficiency”.
Now on to get the Toolbar populated
Get back in to the CUI editor by typing “CUI” (from here on out, remember “no quotes” unless I tell you). While on the “Customize” tab, on the same line as the “Customizations in All Files” line, pick on the down arrows to show all your customization menus.
Scroll down to “Partial Customization Files” and keeping selecting the “+” signs to get out to your “Efficiency” Toolbar. Now switch down to the bottom pane and select the “Create a new command” symbol.
We are going to address all the important items here.
This is what your new command OR Macro will be called, and you will replace this with what you want the actual name to be. This will auto-populate the “Name” field to the right.
Source – “ACAD”
This is the current Menu that the command is registered to. Once you add it to your Efficiency Toolbar, this will show up as “CTS-Custom”. (We will do that shortly).
This is where you will place a description if necessary – Although I rarely do, it is always good practice to describe what your macro does for future folks that may inherit your menu system.
This is where the action happens and your efficiency increases! To see more specifics about the command options in Macros see “Writing Macros” below.
An ID name that you give your macro. I always use ID_name, with “name” being what the tool is.
This is the graphic image that shows up on your toolbar that users see and select to run your macro. Typically these are set to the same. If you have a lot of people who use the LARGE icon option, you may wish to create one for each. Starting out, especially if you are not a creative wiz, I would use an existing button image with a splash of color. I.E. use the save button image for a special file save macro, but color the inside red – then ‘saveas’ a new icon.
At its most basic level, macros are simply automating the prompts that a command throws out to you. Although this is a powerful feature in itself, by stringing multiple commands together, loading and running lisps combined with commands you can do amazing things that will drastically cut back on your keyboard and mouse time. Below are some basics that you will need to know and common issues that you run into when writing macros. Note that this list is not the entire list of macro options, but represents the most commonly needed or utilized.
Basic Macro Options:
Cancel and is the default and most common way to start a macro.
Equal to a keyboard Return. Note: Spaces can also be used but are easily lost in a macro string. I personally do not recommend their use.
Pause for mouse or keyboard input
Use when specifying paths outside of AutoCAD. Note that this is the opposite of what you would see at a command prompt or path description. Example: a command prompt to a network share drive and folder would look like this: “F:\MSTRSYMBOLS\BLOCK.DWG” In a script it looks like this: “F:/MSTRSYMBOLS/BLOCK.DWG”
Quotes – Encapsulates a group. This comes in handy when specifying paths that have spaces in them. For instance the path above has not spaces, but if there was a space between MSTR and SYMBOLS, the macro would assume that was a return. Putting quotes before and after will cause the whole group to be read as one parameter.
Hyphen – this is used to run commands without Dialogue boxes popping up.
Turns ORTHO ON or OFF
Period – This allows you to use built-in commands even if they have been undefined. Useful for CADD managers that have undefined commands.
Now let’s do a quick macro to get your feet wet. We will call this “Super Save”. The purpose of “Super Save” is to zoom extents to get a full view image for previewing (which gets updated on saves), purge our file, audit it, purge it again, save and close it. If you type each of the commands out at your command line, you will see what each letter is answering – remember that the “ ; “ symbol is a return. Time yourself by typing this command out manually and then pick the button and see how much faster it is. And this is just the beginning.
As you may have noticed, this routine is for the still common model space users in the group, it would be simple enough to add a switch to PaperSpace before running the “Zoom” and “Save” options – I’ll leave that for you as homework! (Email me if you need help).
Source: ACAD (Will become “CTS-Custom” once we drag this to our toolbar)
Name: Super Save
Description: Zoom Extents, Purge, Qsave and Close
Element ID: ID_SuperSave
Small/Large Image: super-save
Select Apply to save your work.
To get the Macro button added to your toolbar, drag it from the left lower window pane to the top left window pane until you see a small arrow next to your toolbar, then, drop it. You should see something similar to the right side graphic now.
Yea!! You are on your way now!
In the next post we can skip the toolbar work and concentrate on some more practical macros.