The Mechanical application allows you to execute custom functionality that is not included in the standard menu entries. The functionality is defined in a macro - a script that accesses the Mechanical application programming interface (API).
Macros are normally written in the Python (*.py) programming language. They are run using the default Python engine, which you can change in the Scripting window. For a detailed discussion about working with Python scripts in the Mechanical application (including example scripts), see the Scripting in Mechanical Guide.
To record a macro from the Mechanical interface:
Choose the Scripting option from the group on the Automation tab.
Click the button to start recording the macro.
Execute the Mechanical commands that you wish to record.
Click to finish recording the macro.
You can then edit the resulting Python script in the Scripting Window.
For more information, see Recording Python Scripts (Macros). Be aware that this feature does not support every available Mechanical API command.
To edit and run a macro from the Scripting window:
Choose the Scripting option from the group on the Automation tab.
You can enter Python commands into the Scripting window, record a macro, or click the button in the toolbar to load a macro from a file.
Click the button or press
CTRL-F5to run the macro.
For sample Python scripts that use the Mechanical API, see Scripting Examples.
To run a saved macro from the Mechanical interface:
Choose the Run Macro option from the group on the Automation tab.
Navigate to the directory containing the macro.
Select the file that contains the macro.
Note: For the current release, the Mechanical application also supports macros written in the legacy languages Microsoft's JScript and VBScript. Several macro files are provided with the Ansys Workbench installation under INSTALL_DIR\aisol\DesignSpace\DSPages\macros.