Show in Contents

Add to Favorites

Home: AutoCAD 2010 User Documentation
Examples of Action Macros

Examples of Action Macros

Insert a Block and Change a Dynamic Property Value
Create a New Layer and
Draw Objects
In this example, you
create an action macro that makes a new layer and then draws objects
on the layer to create a two-dimensional top view of a hexagon bolt.
In this
example, you learn how to
- Record and save an action macro
- Record commands and input values to create
and modify a new layer
- Record commands and input values to create
and modify objects
- Insert a user message
- Insert base point
- Pause for user input
- Play back an action macro
Start Recording an Action
Macro
You start recording actions
in the Action Recorder panel. To display the Action Recorder panel
and start recording, follow these steps:
- On the ribbon, click the Manage tab.
- On the Action Recorder panel, click Record.
Record commands and input
values to create and modify a new layer
Once the Action Recorder
starts recording, you use the Layer Properties Manager to create
a new layer. Follow these steps:
- At the Command prompt, enter -layer and
press Enter.
- At the Enter an option [?/Make/Set/New/Rename/ON/OFF/ Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock/ stAte/Description/rEconcile]:
prompt,
enter _M and press Enter.
- At the Enter name for new layer
(becomes the current layer) <0>: prompt, enter Bolt and
press Enter.
- At the Enter an option [?/Make/Set/New/Rename/ON/OFF/ Color/Ltype/LWeight/MATerial/Plot/Freeze/Thaw/LOck/Unlock/ stAte/Description/rEconcile]:
prompt,
enter _C and press Enter.
- At the New color [Truecolor/COlorbook]: prompt,
enter 1 and press Enter.
- At the Enter name list of layer(s)
for color 1 (red) <Bolt>: prompt, press Enter to
assign the color red to the Bolt layer.
If the Action Macro -
Value Not Recorded dialog box is displayed, click the Use the Value
that is Current at Playback link. This will assign the color specified
to the to the recent layer that was created with the Make option.
- Press Enter again to exit the LAYER command.
Record Commands and Input
Values Used to Create and Modify Objects
Creating the Bolt layer
has been recorded. Next, you create a circle and then a six sided
polygon based on the center of the circle for a hexagon bolt. Once the
circle and polygon are drawn, you use the SCALE command to control the
size of the hexagon bolt when the action macro is played back. Follow these
steps:
- At the Command prompt, enter circle and
press Enter.
- At the Specify center point for
circle or [3P/2P/Ttr (tan tan radius)]: prompt, click
in the drawing window.
- At the Specify radius of circle
or [Diameter]: prompt, enter 0.9 and press ENTER.
- At the Command prompt, enter polygon and
press Enter.
- At the Enter number of sides <4>: prompt,
enter 6 and press Enter.
- At the Specify center of polygon
or [Edge]: prompt, use the Center object snap and select
the edge of the circle.
- At the Enter an option [Inscribed
in circle/Circumscribed about circle] <C>: prompt,
enter C for the Circumscribed About
Circle option and press Enter.
- At the Specify radius of circle: prompt,
enter 1 and press Enter.
- At the Command prompt, enter scale and
press Enter.
- At the Select objects: prompt,
select both the circle and polygon and press Enter.
- At the Specify base point: prompt,
use the Center object snap and select the edge of the circle.
- At the Specify scale factor or
[Copy/Reference] <1.0000>: prompt, enter 1 and
press Enter.
Stop Recording and Save
an Action Macro
After all the actions
have been recorded, you stop recording and save the recorded actions
to an action macro file. Follow these steps:
- On the Action Recorder panel, click Stop.
- In the Action Macro dialog box, do the
following:
- In the Action Macro Command Name box,
enter CreateBolt.
- In the Description box, enter Creates
a hexagon bolt.
- Click OK.
Insert a User Message
With a user message,
you can provide instructions or general information about the action
macro to the user before any changes are made to the drawing during
playback. To insert a user message in the action macro, follow these
steps:
- On the Action Recorder panel, click the
title bar to expand the panel.
- In the Action tree, select the CreateBolt
node and right-click. Click Insert User Message.
- In the Insert User Message dialog box,
enter Creates a hexagon bolt by drawing a circle
and polygon. During playback you are prompted for the center point
of the circle and size of the bolt. Click OK.
Insert a Base Point
With insert a base point,
you are prompted to specify a base point when playing back an action
macro. In this action macro, you specify a base point used for the
center point of the circle during playback. Follow these steps:
- On the Action Recorder panel, click the
title bar to expand the panel.
- In the Action tree, select the Circle
action node and right-click. Click Insert Base Point.
Pause for User Input
With a pause for user
input, you are prompted to enter a value when playing back an action
macro. In this action macro, you change the scale factor for the
SCALE command to pause for user input during play back. Follow these steps:
- On the Action Recorder panel, click the
title bar to expand the panel.
- Select the Scale Factor value node under
the Scale action node and right-click. Click Pause for User Input.
Play Back the Action Macro
When you play back the
action macro, you are prompted to specify a base point of a circle
and the scale factor for the SCALE command. To see the results of
the action macro, follow these steps:
- On the Action Recorder panel, on the
Action Macro list, select CreateBolt.
- Click Play.
- In the User Message dialog box, click
Close.
- When prompted to specify a base point,
click a coordinate point in the drawing window.
The circle and polygon
are drawn.
- When prompted for a scale factor, enter
a numeric value (such as 1 or 0.25) at the Command prompt and press
Enter.
The circle and polygon
are scaled based on the scale factor entered.
- In the Action Macro - Playback Complete
dialog box, click OK.
Commands
ACTRECORD
Starts
the Action Recorder.
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.
ACTBASEPOINT
Inserts
a base point in an action macro.
CIRCLE
LAYER
Manages layers and layer
properties.
POLYGON
Creates an equilateral
closed polyline.
RIBBON
SCALE
Enlarges or reduces
selected objects, keeping the proportions of the object the same
after scaling.
System Variables
Utilities
Command Modifiers