AutoCAD 2009: Action Recorder (Circles and Lines AutoCAD Tutorial)

Just click a button to record your actions; no programming skills required.

An AutoCAD Macro recorder has been on my wish list of desired features for a long time, so I was absolutely thrilled that AutoCAD 2009 has finally fulfilled my dreams with a low-stress means of recording actions for future use. You know this new feature has got to be good because those fabulous Express Tools programmers wrote it. (And you know I can't possibly say enough good things about them!)

The concept is simple. We all have tedious tasks that we do throughout our drawing day. Maybe we could write an AutoLISP routine or a menu macro to automate these tasks, but who has time to figure that out? The new Action Recorder literally lets you record your actions once, and then you can play them back over and over in the future. No programming skills needed here! You just press the Record button.

Your first task is to figure out what those tedious tasks are. Take note as you use AutoCAD and see if you can identify a series of steps that you perform a lot. It might not necessarily be the creation of an object (since we tend to create blocks to speed that process), but surely you've

The Action Recorder panel on the Tool tab of the new Ribbon bar.

encountered repetitive steps during the editing process.

The Action Recorder is located in the Tools tab of the new Ribbon and also in the Tools pulldown menu. I much prefer the Ribbon version.

The process is simple:

Hit the Record button.

Perform the AutoCAD commands you wish to record.

Stop the recording, and give the macro a name.

After you've recorded your macro, you can replay it as many times as you want, whenever you want.

Let's make a simple macro that does the following:

Create a new layer called Test, give it the color Red, and make it current.

Draw a circle.

Copy that circle four times.

Erase the first circle.

A red dot by your cursor indicates you are recording.

Sound easy enough? I'll start by hitting the Record button. You will know when you are recording because there will be a red dot on your screen by your cursor. There is obviously no rush as AutoCAD is only recording the steps, not the length of time it takes to perform those steps.

So here's the process for our example:

Hit the Record button to start creating the macro.

Enter the Layer Properties manager to create the layer Test, assign it the color red, and make it current.

Enter the Circle command, select the center point and the radius.

Enter the Copy command and make four copies.

Enter the Erase command and erase the original circle.

Hit the Stop button.

Give the macro a name.

After you hit the Stop button, you will be asked to provide a name for your macro.

Now undo all the steps (back past creating your layer) and hit the Play button to test your macro! Don't blink or you just might miss it (it plays so very quickly).

Macro Action Tree
You'll see that all of your macro steps are saved in the Action Tree.

The Action Tree displays all the steps in your macro.

You can make your macros even more powerful by adding options for user input. For example, maybe I want to let the user determine where that first circle is drawn. A right-click on the Action Tree where it recorded the coordinate for the center of the circle allows me to Request User Input.

Make your macros more powerful by inserting a Request User Input option.

The next time I run my macro, it will stop at the Circle command and ask me to select the center of the circle.

I could also right-click on the radius of 5.4543 and select Edit to change the value to something else if I chose, maybe round it off to a value of 5, for example.

Notice that my Copy command is copying relative to the first drawn circle. That is indicated by the symbol in front of all the coordinates. That means that the copies are always drawn relative to the location of the first circle. What if I didn't want the copies to be relative to the first circle but to be at absolute locations in my drawing? No problem, simply right-click on the coordinates and change the Relative to Previous option from the shortcut menu.

Convert relative coordinates to absolute from the shortcut menu.

Another powerful option is the ability to insert a user message. Maybe I want to allow my user to determine if he wants to erase the first circle or not. I simply move down the Action Tree to the Erase command and select Insert User Message from the shortcut menu. This displays a dialog box that allows me to key in my own customized message. This could be used to include specific directions of any type.

Insert a user message into your macro to include valuable instructions.

Now if I play back my macro, it asks me to select the center of my circle and asks me if I really want to erase the first circle. Clicking No would end my macro without erasing.

User messages can be very helpful in your macros.

So where do these mystery files get saved? That depends on what you have set in the Options dialog box (located on the Files tab). By default your macros (with an extension of ACTM) will go to the standard location under Documents and Settings. You can add your own location to store macros, and this can make it easy to share them with your coworkers.

Set your own Action macro location in the Options command.

All action macros in the directories specified in Options can be found in the list of macros in the Action Recorder panel. Execute any action macro by dropping down the list to select the desired macro and hitting the Play button. You can also execute these macros at the Command line. If I key in the word Test at the Command line, it will execute my nifty circle macro.

Note: AutoCAD won't let you create a macro with the same name as an existing command for obvious reasons. It will, however, let you create a macro that has the same name as an alias, so be careful what you name them! For example, if you create a macro called E, you will no longer be able to key in E for Erase. Of course, if you do this by accident, simply rename or delete the macro. You AutoLISP programmers should also take note that these macros beat out your LISP routines should you have a macro with a duplicate name.

Last, but not least, you can control some preferences for your Action Macro (also found in the Action Macro panel). You can control whether you want the Action Tree to expand on playback or recording and whether or not you want to be prompted for an Action Macro name. If you choose to turn off the prompt for name, an incremental variation of ActMacro001 will be assigned.

Set the Action Recorder to work the way you want in Preferences.

The Action Recorder is my favorite feature in AutoCAD 2009. Give this gem a try, and you might just find yourself automating many tedious tasks in your everyday drawing life, giving you a little more time to spend on yourself!

Until next month, happy AutoCADing!

About the Author: Lynn Allen

Autodesk Technical Evangelist Lynn Allen guides you through a different AutoCAD feature in every edition of her popular "Circles and Lines" tutorial series. For even more AutoCAD how-to, check out Lynn's quick tips in the Cadalyst Video Gallery. Subscribe to Cadalyst's free Tips & Tools Weekly e-newsletter and we'll notify you every time a new video tip is published. All exclusively from Cadalyst!Follow Lynn on Twitter