Action Macro Example: 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 2D top view of a hexagon bolt.

In this example, you learn how to

Start Recording an Action Macro

You record actions with the Action Recorder panel. To display the Action Recorder panel and start recording, perform this step:

Record commands and input values to create and modify a new layer

Once recording is started, you can use the Layer Properties Manager to create the new layer named Bolt. Follow these steps:

  1. At the Command prompt, type -layer and press Enter.
  2. At the prompt, Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile], type m and press Enter.
  3. At the prompt, Enter name for new layer (becomes the current layer) <0>, type Bolt and press Enter.
  4. At the prompt, Enter an option [?/Make/Set/New/Rename/ON/OFF/Color/Ltype/LWeight/TRansparency/MATerial/Plot/Freeze/Thaw/LOck/Unlock/stAte/Description/rEconcile], type c and press Enter.
  5. At the prompt, New color [Truecolor/COlorbook], type 3 and press Enter.
  6. At the prompt, Enter name list of layer(s) for color 3 (green) <Bolt>, press Enter to assign the color Green 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.

  7. Press Enter again to exit the -LAYER command.

Record Commands and Input Values Used to Create and Modify Objects

Next, you create a circle and then a six sided polygon based on the center of the circle for the bolt. Once the circle and polygon are drawn, you use the SCALE command to control the size of the bolt when the action macro is played back. Follow these steps:

  1. At the Command prompt, type circle and press Enter.
  2. At the prompt, Specify center point for circle or [3P/2P/Ttr (tan tan radius)], click in the drawing area.
  3. At the prompt, Specify radius of circle or [Diameter], type 0.9 and press Enter.
  4. At the Command prompt, type polygon and press Enter.
  5. At the prompt, Enter number of sides <4>, type 6 and press Enter.
  6. At the prompt, Specify center of polygon or [Edge], use the Center object snap and select the edge of the circle.
  7. At the prompt, Enter an option [Inscribed in circle/Circumscribed about circle] <C>, type c and press Enter.
  8. At the prompt, Specify radius of circle, type 1 and press Enter.
  9. At the Command prompt, type scale and press Enter.
  10. At the prompt, Select objects, select both the circle and polygon and press Enter.
  11. At the prompt, Specify base point, use the Center object snap and select the edge of the circle.
  12. At the prompt, Specify scale factor or [Copy/Reference] <1.0000>, type 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:

  1. Click Manage tab Action Recorder panel Stop.
  2. 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.
  3. 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:

  1. On the Manage tab, expand the Action Recorder panel.
  2. In the Action Tree, select the CreateBolt node and right-click. Click Insert User Message.
  3. 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:

  1. On the Manage tab, expand the Action Recorder panel.
  2. 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:

  1. On the Manage tab, expand the Action Recorder panel.
  2. 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:

  1. Click Manage tab Action Recorder panel, in the Action Macro list, select CreateBolt.
  2. Click Play.
  3. In the User Message dialog box, click Close.
  4. When prompted to specify a base point, click a coordinate point in the drawing area.

    The action macro creates the circle and polygon.

  5. When prompted for a scale factor, enter a numeric value (such as 1 or 0.25) at the Command prompt and press Enter.

    The action macro scales the circle and polygon based on the scale factor entered.

  6. In the Action Macro - Playback Complete dialog box, click OK.