cadalyst
AutoCAD

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

31 May, 2008 By: Lynn Allen

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

figure
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:

  1. Hit the Record button.
  2. Perform the AutoCAD commands you wish to record.
  3. 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:

  1. Create a new layer called Test, give it the color Red, and make it current.
  2. Draw a circle.
  3. Copy that circle four times.
  4. Erase the first circle.

figure
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:

  1. Hit the Record button to start creating the macro.
  2. Enter the Layer Properties manager to create the layer Test, assign it the color red, and make it current.
  3. Enter the Circle command, select the center point and the radius.
  4. Enter the Copy command and make four copies.
  5. Enter the Erase command and erase the original circle.
  6. Hit the Stop button.
  7. Give the macro a name.

figure
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.

figure
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.

figure
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.

figure
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.

figure
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.

figure
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.

figure
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.

figure
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!


More News and Resources from Cadalyst Partners

For Mold Designers! Cadalyst has an area of our site focused on technologies and resources specific to the mold design professional. Sponsored by Siemens NX.  Visit the Equipped Mold Designer here!


For Architects! Cadalyst has an area of our site focused on technologies and resources specific to the building design professional. Sponsored by HP.  Visit the Equipped Architect here!