Using macros to control PowerShape

Macros enable you to create automatic routines for repetitive operations. For example, you might want to loop through all the surfaces in a model and change the colours. Macros are usually created by recording a sequence of operations. The resulting file can then be edited using a text editor. The macro language is covered in Customising PowerShape.

Note: Use the Macros page of the Options dialog to set the mouse options to be used when recording macros.

Run

Select this option to run a previously recorded macro.

  1. Click Home tab > Macro panel > Run to display the Run Macro dialog.
  2. Select the macro you want to run.
  3. Click Open to run the macro.

Step

Select this option to run the macro one step at a time. If there is a macro nested within the macro you are stepping, the nested macro is run. You are then returned to the macro you are stepping through. A nested macro is one which is initialized within a macro that is already running.

  1. Click Home tab > Macro panel > Stepto display the Step Through Macro dialog.
  2. Select the macro to step through.
  3. Click Open to begin stepping through the macro.
    Note: Macros which are nested within the macro you are stepping are run rather than stepped. If you want to step nested macros, use the Step All option.
  4. Press Entereach time you want to carry out another step.
  5. To stop stepping through the macro, select Home tab > Macro panel > Abandon.

Step All

Select this option to run the selected macro and any nested macros to be run one line at a time.

  1. Click Home tab > Macro panel > Step All to display the Step Through Macro dialog.
  2. Select the macro to step through.
  3. Click Open to begin stepping through the macro.
    Note: Macros that are nested within the macro you are stepping through, are also stepped through.
  4. Press Enter each time you want to carry out another step.
  5. To finish stepping through a macro, select Home tab > Macro panel > Abandon.

Continue

Use this option to run the remainder of a stepping macro.

Until

This option is only available when the macro is stepping.

When issued, the command prompts for a regular expression. It will then run the macro up to and including the first line that contains the regular expression. It will then revert to stepping.

The regular expressions used are based on Perl and are caseless, so if the macro is:

if ($error == 1) {

print e1

} elseif ($error == 2) {

print e2

}

the following expressions would all match the last but one line:

print e2

p.*2

PRINT E2

The advantage of this command is that it makes it easier to step through long macros or macros that include modal dialogs. Other techniques to do this require editing the macro.

Abandon

Use this option to stop a running or stepping macro.

Note: Abandon will only be active if you are currently running or stepping a macro.

Record

Select this option to record a macro.

  1. Click Home tab > Macro panel > Record to display the Record Macro dialog.
  2. In the File name box, enter the name of the file you want to record to.

    If you enter the name of an existing file, it is overwritten with the new commands.

  3. Click Save to begin recording the macro.
  4. Perform the commands you want to record.
  5. Select Home tab > Macro panel > Record to stop recording. You can use any text editor to view and edit a macro.