Scripts and macros¶
With Modelio, you can run scripts written in Jython:
either from the Modelio command line
or in a dedicated view called the Script view
You can also save these scripts as macros, which you can then use as often as you wish. These macros are defined and organized in a dedicated window, and can be run through an associated pop-up menu command, an associated toolbar icon or through the macro window itself.
The script view¶
The script view¶
To open the script view, run the Views/Show script view command.
The script view tab.
The script view toolbar.
The script output zone.
The script input zone.
The script view toolbar¶
The script view toolbar buttons run the following operations:
: Runs the script entered in the script input zone and displays the result in the script display zone.
: Clears the entire contents of the script view output zone.
: Loads an existing script.
: Loads an existing script and automatically runs it.
: Saves the script entered in the script input zone.
: Activates the script debug mode. In this mode, the script input zone is not cleared when a script is run.
Two keyboard shortcuts exist for the script view:
Ctrl+Enter: Runs everything in the script input zone.
Shift+Enter: Runs only what is selected in the script input zone.
Entering and running Jython scripts¶
Entering and running a Jython script¶
Saving a script for reuse¶
If you intend to reuse a Jython script, you may want to save it, as shown below.
Saving a Jython script¶
Creating a new macro¶
If you intend to reuse a Jython script several times, you may want to create a new macro from it, as shown in the screenshots below.
Opening the macro catalog and adding a Jython script file¶
When creating a new macro, you can choose to make it available only in the current project, or else on all the projects in your workspace.
Now define your macro by carrying out the operations shown below.
Defining a new macro¶
The name of the macro is important, because if you dont associate an icon with the macro, it is this name which will appear in the Modelio toolbar.
The result of these operations is shown in the screenshot below.
The newly created macro can be run from the Modelio toolbar or the Macros menu¶
When you run a macro, the script view automatically appears, showing both the Jython script in the input zone and the result in the output zone.
Running a macro¶
Three types of macro can be run from the Macro catalog window:
- Modelio macros, which are predefined macros delivered as standard with Modelio
- Workspace macros, which are available on all projects in your workspace
- Project macros, which are available only on the current project
Macros are run via their associated buttons and context menu commands, where these have been defined.
Macros can also be run through the macro catalog window (accessed via the File/Edit macro catalog command). In this window, simply select the macro of your choice and click on Run.