15.2. Macros

VisIt’s Command window contains controls that allow you to record most GUI actions and view Python scripting code needed to accomplish those actions. The Command window provides 8 conventional tabs that serve as destinations for recorded Python coding. In addition to those 8 tabs, there is a special tab called Macros that shows the contents of the visitrc file. If you record Python code to the Macros tab then that Python code is turned into a function that can be called in response to a button click from a button in the Macros window.

15.2.1. Recording a macro

Here are the steps involved in recording a macro.

  1. Open the Command window and choose to Store commands in Macros.

    ../../_images/commandwindow.png

    Fig. 15.2 Command Window Macros Tab

  2. Click the Record button

  3. Perform any GUI actions that you want to record to a single button click.

  4. Click the Stop button in the Command window.

  5. Enter the name of a Python function in which to store your set of recorded commands.

    ../../_images/macrorecord1.png

    Fig. 15.3 Setting the Python funtion name

  6. Enter the text for the macro button as it will appear in the Macro window.

    ../../_images/macrorecord2.png

    Fig. 15.4 Setting the Macro Button text

  7. Now, the Macros tab will contain a function for your recorded commands and it will call the RegisterMacro function from the VisIt Python Interface to associate your Python function with the named button. Note: Remembe that you can edit the recorded Python code to suit your needs. You can generalize the code so it can, for example, operate on the active database instead of a specific database. The state information that you need to generalize can often be returned by the GetGlobalAttributes(), GetWindowInformation(), or GetMetaData() functions.

  8. Click the Update macros button to make VisIt update the buttons in the Macros window so it will contain your new button.

    ../../_images/macrorecord3.png

    Fig. 15.5 The final Macro Button that is produced

  9. No further steps need to be taken to save your macro since the macro definitions in the Macros tab of the Command window will be automatically saved to your visitrc file.

  10. Click the new button in the Macros window whenever you want to replay the recorded set of commands.

Warning

Users should be aware that VisIt’s macro recording feature records only those operations that use methods in VisIt’s python interface. Any operations that would not ordinarily require VisIt’s python methods to complete are not recorded. In particular, operations involving interaction with the file system such as changing the current working directory and creating a directory (or folder) are not recorded.