Putting the Action Into Macros

Wouldn't it be great to simplify your workflows and repetitive tasks through automation? I know, what you might be thinking… "Sounds great, but I'm not a programmer."

You don't need to be a programmer to automate repetitive tasks with action macros. You just need to know how to use AutoCAD, more specifically, how to use commands and system variables. As you use commands, certain commands are often used frequently together and in the same order, this is known as a command sequence. Command sequences make the best candidates to be automated.

Action macros are a recorded sequence of commands, options, and values that can be played back in any drawing. You might create an action macro that:

Note: The video doesn't contain audio or closed captions.
Note: Steps, images, and videos may differ slightly from your version of the product.

Which Commands and Actions Can Be Recorded?

Most commands can be recorded, such as the LINE command to draw lines, CHPROP command to change the properties of an object, and the LAYER command used to manage layers in a drawing.

The commands that can't be recorded are related to:

You can find a list of AutoCAD commands that can't be recorded in the Customization Guide in the topic About Recording Action Macros.

An action is the smallest interaction in AutoCAD that can be recorded, these general interactions can be recorded:

You can find a list of actions and user interfaces that can be recorded in the Customization Guide in the topic About Recording User Interface Elements.

Record an Action Macro

Action macros are recorded using the Action Recorder located on the Manage tab of the ribbon. Think of the Action Recorder as AutoCAD's version of an audio recorder or digital video recorder (DVR).



When recording starts, a red circle appears adjacent to the crosshairs letting you know the Action Recorder is actively listening for actions.



Let's look at recording an action macro that could be used to setup a drawing. This action macro will do the following:

  1. Create a new drawing.
  2. Add the layer "Dimensions" and assign the layer the color 3.
  3. On the ribbon, click Manage tab > Action Recorder panel > Record. Find
  4. At the Command prompt, enter CLAYER and then enter a name of Dimensions.

    Notice the CLAYER system variable is recorded and shown in the Action Tree.



  5. At the Command prompt, enter OSMODE and then enter a value of 39.

    The value 39 sets the midpoint, endpoint, center, and intersection running object snaps current.

  6. At the Command prompt, enter DIMLINEAR.
  7. At the Specify first extension line origin prompt, specify a point in the drawing.
  8. At the Specify second extension line origin prompt, move the cursor to the right and specify a point.

  9. At the Specify dimension line location prompt, move the cursor up and specify a point.

  10. At the Command prompt, enter LAYERP.

    The previous layer is restored.

  11. On the ribbon, click Manage tab > Action Recorder panel > Stop. Find
  12. In the Action Macro dialog box, Action Macro Command Name text box, enter ADDLINEARDIM.

  13. Optionally, enter a description for the macro in the Description text box.
  14. Click OK to save the action macro to a file with the ACTM extension.

    If you expand the Action Record panel, the completed macro should look like the following image.



  15. Click the pin button on the Action Recorder panel to allow the panel to collapse.

Playback an Action Macro

After an action macro has been recorded, it can be played back using one of the following methods:

The following steps explain how to playback the ADDLINEARDIM action macro that was recorded earlier:

  1. Create a new drawing and turn off Object Snap (F3).
  2. Add the layer "Dimensions" to the drawing, but don't set it current.
    Note: If the layer doesn't exist, you will get an error when playing back the macro. To avoid this, you could use the -LAYER command with the Make option to create the layer, if it doesn't exist in the drawing already, instead of the CLAYER system variable to set a layer current.
  3. At the Command prompt, enter ADDLINEARDIM.
  4. In the Action Macro – Playback Complete message box, click Close.

    Object snap should now be enabled with a linear dimension drawn on the Dimensions layer.



Important: If commands were used during the recording of an action macro and those commands aren't available during playback, the action macro will not complete as expected. The same is true if a layer or style was set current as part of an action macro but isn't available in the drawing during playback.

Edit and Request Input an Action Macro

After an action macro has been saved to an ACTM file, you can make the following types of changes to it:

Note: Commands can't be inserted or appended to an action macro after recording has been completed.

You make changes to an action macro by making sure it is current in the Action Macro drop-down list and expanding the Action Recorder panel to see the Action Tree.





With the Action Tree expanded:

The following steps explain how to change the name of the layer to Dims and prompt the user to provide the locations of the extension and dimensions lines during playback:

  1. On the ribbon, click Manage tab > Action Recorder panel. From the drop-down list, choose ADDLINEARDIM.

  2. Click the title bar of the Action Recorder panel to expand it and display the Action Tree.
    Note: If the Action Recorder panel doesn't expand, try setting the ACTUI system variable to a value of 7 and playback the action macro. If the panel still doesn't expand, close and restart the product.
  3. In the lower-left corner of the expanded panel, click the pin button to keep the Action Recorder panel from collapsing.

  4. With the Action Recorder panel expanded and the Action Tree visible, select and then double-click the recorded String value of Dimensions under the CLAYER system variable and enter a new value of Dims.

    Now when the action macro is played back, the Dims layer will be set current instead of Dimensions.



  5. Under the DIMLINEAR command node, right-click over each coordinate value and choose Pause for User Input.

    Each coordinate value should now appear with italic text and have a Silhouette badge overlay. Now during playback, you will be prompted to specify a location for the first and second extension lines along with the dimension line.

  6. Create a new drawing and then add then a layer named Dims.
  7. Playback the action macro.
  8. Specify three points to define the dimension.

    The dimension is placed on the Dims layer this time.

Note: If you notice a <View Change> node in your action macro, you might not need to keep it. A <View Change> node is used to restore the drawing view that was current when the macro was recorded; for example, it might be used to position the in-place text editor into view or the result of a pan/zoom operation.

Before removing a <View Change> node, create a copy of your action macro with the Action Macro Manager dialog box (ACTMANAGER command) and then remove the <View Change> node from the copy of the action macro. Once the action macro has been copied, followed these steps:

  1. If the action macro to edit isn't selected, choose it from the Action Macro drop-down list.
  2. Expand the Action Recorder panel if it isn't already and scroll to the <View Change> node.
  3. Right-click over the <View Change> node and choose Delete.
  4. In the Action Macro – Confirm Deletion of Action Node, click Delete.

  5. Create a new drawing and playback the action macro again.

    This time, the drawing's view shouldn't be changed unless desired.

Manage and Share an Action Macro (ACTM) Files

Action macros are stored in ACTM files. ACTM files can be stored in a shared location, allowing for multiple users to use them. There are two types of folders the Action Recorder and AutoCAD look in for ACTM files:

These folder locations are defined under the Action Recorder Settings node on the Files tab of the Options dialog box. The following steps explain how to add an additional location for ACTM files:

  1. In the drawing window, right-click and choose Options.

  2. In the Options dialog box, Files tab, expand the Action Recorder Settings node.

  3. Select the Additional Actions Reading File Locations node.
  4. Click Add and then click Browse.
  5. In the Browse for Folder dialog box, choose the folder that contains any additional ACTM files to load into AutoCAD, and click Open (or OK).
  6. Click OK to save the changes made in the Options dialog box.

Summary

Action macros allow you to instruct AutoCAD to execute multiple commands with consistent results which help to simplify workflows, reduce repetitive tasks, and enforce CAD standards though automation. Automation can free up time and allow you to focus on your designs rather than the design tool.

Additional Things to Know When Recording Actions

Action Macros Commands and System Variables

Here are some frequently used commands and system variables related to action macros.

Command Description
ACTBASEPOINT Inserts a base point or base point prompt in an action macro.
ACTMANAGER Manages action macro files.
ACTRECORD Starts the recording an action macro.
ACTSTOP Stops the Action Recorder and provides the option of saving the recorded actions to an action macro file.
ACTUSERINPUT Pauses for user input in an action macro.
ACTUSERMESSAGE Inserts a user message into an action macro.
System Variable Description Default Value Saved In
ACTPATH Specifies the additional paths to load action macros from for playback. "" Registry
ACTRECORDERSTATE Specifies the current state of the Action Recorder. 0 Not-saved
ACTRECPATH Specifies the path used to store new action macros. "" Registry
ACTUI Controls the behavior of the Action Recorder panel when recording and playing back macros. 6 Registry