| iTool User's Guide: Working with Macros |

## Using the Macro Editor

You can use the Macro Editor to modify existing macros and create new macros. The Macro Editor is launched automatically after you record a macro interactively. You can also launch the Macro Editor at any time by selecting Operations Macros Macro Editor from any iTool.

The Macro Editor is a system-wide dialog, shared by all current iTools. Closing all current iTools does not close the Macro Editor.

Figure 8-8: The Macro Editor

Figure 8-8: The Macro Editor

Figure 8-8 shows the Macro Editor with the History folder expanded to show the history items that were generated while the iImage tool was open (that is, all iImage operations, whether recorded in a macro or not). The Macros folder in the upper-right panel shows a macro with its SetProperty item selected.

### Understanding the Macro Editor

The Macro Editor consists of four panels and two sets of add/remove buttons. The four panels consist of the two macro panels on the top and the two source panels on the bottom. You use the add/remove buttons to move operations and settings from the source panels to the macro panels.

#### The Menu Bar

The following menus appear on the Macro Editor menu bar:

- File

- Edit

- Run

- Help

You can use the Edit and Run operations in a right-click context menu on items in the macro and source trees.

The File menu, shown in Table 8-1, contains tools for creating, importing, exporting, and saving macros.

Table 8-1: The File Menu

Table 8-1: The File Menu
Menu Selection | Function
--- | ---
New | Creates a new macro in the macro tree, with a name based on `New Macro.' If New Macro already exists, then the new name is New Macro (1) and so on until the system finds a uniquely numbered name.
Import... | Imports a macro from an external file. See Importing and Exporting Macros for details.
Export... | Exports the selected macro to an external file. See Importing and Exporting Macros for details.
Save | Saves all macros to external IDL SAVE files with names based on the macro names.
Close | Closes the Macro Editor, prompting you to save any unsaved macro changes.

The Edit menu, shown in Table 8-2, contains tools for editing, deleting, duplicating, and moving items within the macro and source trees.

Table 8-2: The Edit Menu

Table 8-2: The Edit Menu
Menu Selection | Function
--- | ---
Cut | Copies the selected item to an internal clipboard and removes the item from the tree.
Copy | Copies the selected item to an internal clipboard.
Paste | Pastes the contents of the internal clipboard into the tree.
Delete | Deletes the selected item without making a copy. If the selected item is a SetProperty item and the last selection was in the macro property sheet, this action deletes selected properties from the SetProperty item. If the last selection was in the macro tree, the whole SetProperty item is deleted.
Duplicate | Duplicates the selected item.
Move Item Up | Moves the selected item up one position in the tree.
Move Item Down | Moves the selected item down one position in the tree.

The Run menu contains only one operation: Run Macro, which runs the selected macro. See Running from the Macro Editor for details.

The Help menu opens the online help for the Macro Editor.

#### The Macro Tree

The macro tree (top left) contains folders for existing macros, as shown in Figure 8-9. Macros are indicated by the gears folder icon. Macro items are indicated by their own object icons or by the SetProperty icon.

Figure 8-9: The Macro Editor's Macro Tree

Figure 8-9: The Macro Editor's Macro Tree

Clicking on an item in the tree selects the item and displays its property sheet to the right of the tree panel. Right-clicking within the tree brings up the context menu of available actions (see The Menu Bar). If you right-click on a tree item, then that item is selected.

For more information on these items, see Macro Items.

#### The Macro Property Sheet

The macro property sheet (top right) lets you set properties of macro folders and items.

To see a macro's properties, click on its folder in the macro tree. The macro's properties appear in the macro property sheet, as shown in Figure 8-10. To change any of the properties, click on it in the sheet and make the modification you want.

Figure 8-10: The Macro Editor's Macro Property Sheet: Macro Properties

Figure 8-10: The Macro Editor's Macro Property Sheet: Macro Properties

Macros have several properties, described in Table 8-3.

Table 8-3: Macro Property Values

Table 8-3: Macro Property Values
Property | Value
--- | ---
Name | Used to select the desired macro from the Run Macro dialog (for more information, see Running from the Operations Menu). Also serves as the basis for the filename of a saved macro.
Description | Used to describe the behavior or purpose of the macro. Its value appears in the Run Macro dialog's Description field when you select a macro from the list.
Display intermediate steps | Typically set to False so that the display updates only on completion of the macro. Set this property to True to display each step of the macro, which might be useful when using a macro to animate a series of actions.
Step delay (seconds) | Used to specify the time in seconds to delay between each step of the macro. The default value is 0.0. The minimum value is 0.0, and the maximum value is 60.0. Note - You can also add the Delay operation to a macro to create a single specific delay (see Delay Operation Item).

Note If Display intermediate steps is set to False (the default value), updates to the display are suppressed while a macro is being run. Operations that typically update the display, such as the Volume Render operation, do not change the display if Display intermediate steps is set to False.

To see an individual macro item's properties, click on the item in the macro tree. The properties appear in the macro property sheet, as shown in Figure 8-11. To change any of the properties, click on a property in the sheet and make the modification you want.

Figure 8-11: The Macro Editor's Macro Property Sheet: Macro Item

Figure 8-11: The Macro Editor's Macro Property Sheet: Macro Item

You can modify any properties of a macro item except for user-defined properties, which are not available for modification.

#### The Source Tree

The source tree (bottom left), as shown in Figure 8-12, contains the following items that you can use for macro creation:

- History items, grouped by tool (see History Items)

- Visualizations (see Visualization Items)

- Annotations (see Annotation Items)

- Macro tool items (see Macro Tools Items)

- Tool menu items (see Tool Menus Items)

Figure 8-12: The Macro Editor's Source Tree

Figure 8-12: The Macro Editor's Source Tree

You can use these property settings and operations as a source for macro items. Selecting one of these items displays its properties in the source property sheet next to the tree panel. While the visualizations and annotations cannot be used directly in macros, you can use their properties as the source for macro property settings. The source tree also contains operations for the current tool, in the Tool Menus Operations subfolder, which you can use as a source for macro operations.

Clicking on an item in the tree selects the item and displays its property sheet to the right of the tree panel. You cannot multi-select within the tree. Right-clicking within the tree brings up the context menu of available actions (see The Menu Bar). If you right-click on a tree item, then that item is selected.

#### The Source Property Sheet

The source property sheet (bottom right) displays the properties of items in the source tree to its left. As described above, properties can be used as source items for macros.

Figure 8-13: The Macro Editor's Source Property Sheet

Figure 8-13: The Macro Editor's Source Property Sheet

Figure 8-13 shows the properties for the Line operation, found in the source tree's Annotations folder. You can multi-select properties in the sheet. Selected properties may be moved to a macro property setting item. Although all properties in the source property sheet are grayed out (desensitized), you can select them for creation of SetProperty macro items (for more information, see SetProperty Settings).

Note User-defined properties are available only if they are part of a macro recording; they will apply like any other property during playback. You cannot otherwise use a user-defined property (moving, copying, modifying, etc.) in the macros system.

#### The Add and Remove Buttons

There are two sets of Add and Remove buttons, one for the source and macro trees and one for the source and macro property sheets. Both sets have similar behavior.

##### The Item Add Button

The item Add button (in the left pair) copies items from the History and operations folders up into macros. If a macro folder is selected in the macro tree then the new item is placed at the end of existing items. If a macro item is currently selected in the macro tree, then the new item is added to the macro folder, immediately following the selected macro item. If the top-level Macros folder is selected, then a new macro is created, and the item is placed within it.

With a visualization selected, the Add button adds a `Visualization...' operation to the macro. This item will make a running macro present the Insert Visualization dialog to let you define parameters and insert a new visualization. Note that the Show Dialog property is set to True because you must define the parameters interactively, unlike with an Insert Visualization operation that has been recorded or copied from history.

You can select annotations in the source tree to select their properties, but you cannot move the annotations directly up into macros because they require initialization with data. The exception is annotations in the History folder (for more information, see Annotation Items).

##### The Item Remove Button

The item Remove button (in the left pair) removes the selected item or folder from the macro tree.

##### The Property Add Button

The property Add button (in the right pair) moves selected properties up into a new or existing SetProperty operation in a macro. Running a macro with a SetProperty operation applies the property setting to the selected visualization, letting you set the specified property on any applicable object.

Note Once a property setting is added to a macro, it is no longer tied to a particular visualization type.

If you add a desensitized property to a macro item, the property will be sensitized (not grayed out) in the macro property sheet.

If you select an existing SetProperty item in the macro tree, IDL adds properties to it instead of creating a new SetProperty item.

Figure 8-14: An Example Using the Property Add Button

Figure 8-14: An Example Using the Property Add Button

Figure 8-14 shows a SetProperty macro item created by selecting the Plot visualization in the source tree and three properties (Color, Line Style, and Thickness) in the source property sheet. The property Add button copied the desired property settings up into a SetProperty macro item containing all three properties.

##### The Property Remove Button

The property Remove button (in the right pair) removes any selected properties from SetProperty items. It is not enabled for other types of macro items.

IDL Online Help (March 01, 2006)