Recording a Macro

The easiest way to create your Java macro file is to record one in Simcenter STAR-CCM+ while you perform all the steps that belong in the macro file.

To record a Java macro:

  1. Select File > Macro > Start Recording....

    Alternatively, click the (Start Recording) toolbar button.

    This action opens a variant of the standard, operating system-specific Save dialog that is set up for creating macro files.



  2. Navigate to the directory where you want to place this macro and give it a name (the .java extension is automatically added to the file name).
  3. If the purpose of the macro does not involve specific adjustments to graphical elements such as scenes and displayers, deactivate the Include Graphics Commands option near the top of the dialog.

    This option excludes graphics code from the macro.

When the macro is recording, each action you perform in Simcenter STAR-CCM+ adds an associated command to the macro file. You can see which commands are being added to the macro by selecting the macro tab in the Output window; the tab has the same name as the macro file. If you wish to perform some steps in the simulation, but do not want them to be included in the macro, it is possible to pause the recording. When you are ready to record more steps for the macro, you can resume recording. The macro is saved when you stop recording.

It is recommended that you plan which steps to include in the Java macro before you begin recording. This planning ensures that the macro is not cluttered with superfluous commands, and is easier to edit.

Pausing and Resuming the Recording

To interrupt recording of the macro:

  1. To interrupt recording of the macro, select File > Macro > Pause Recording.
  2. Alternatively, click the (Pause Recording) toolbar button.

    Actions that you trigger in the workspace are not added to the macro file while recording is paused. The pause icon in the toolbars becomes highlighted ( ) when macro recording is paused. This action is only available if a macro is being recorded.

  3. To resume recording, select the same menu item or toolbar button.

    Alternatively, click the (Pause Recording) toolbar button.

    The pause icon in the toolbars reverts to normal ( ) once this action has been triggered.

Excluding Visualization Code from the Macro

By default, macros include code for all adjustments to displayers, scenes, and other graphical elements in the Simcenter STAR-CCM+ workspace. The purpose of a macro can even be just to add an item like a derived part. This extra code can be inconvenient if you plan to run this macro in batch, or if you want to edit the macro.

To use this feature, deactivate the Include Graphics Commands checkbox in the Save dialog.

This action causes the macro recording feature to ignore changes to scenes, displayers, view, animation, and part groups for the objects affected.

Saving the Macro

To finish recording and save a macro:

  • Select File > Macro > Stop Recording.

    Alternatively, click the (Stop Recording) toolbar button.

    This action is only available if a macro recording is in progress or is paused.

    The macro file that you had named in the previous step contains the Java code that maps to the actions you carried out while the recorder was active.