Scripts and macros

Introduction

With Modelio, you can run scripts written in Jython:

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

2

The script view

Key:

  1. To open the script view, run the Views/Show script view command.

  2. The script view tab.

  3. The script view toolbar.

  4. The script output zone.

  5. The script input zone.

The script view toolbar

The script view toolbar buttons run the following operations:

Note: Two keyboard shortcuts exist for the script view:

Entering and running Jython scripts

9

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.

10

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.

11

Opening the macro catalog and adding a Jython script file

Note: 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.

12

Defining a new macro

Note: 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.

13

The newly created macro can be run from the Modelio toolbar or the Macros menu

Note: 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:

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.