Scripts and macros

Introduction

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

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:

  • 3: Runs the script entered in the script input zone and displays the result in the script display zone.

  • 4: Clears the entire contents of the script view output zone.

  • 5: Loads an existing script.

  • 6: Loads an existing script and automatically runs it.

  • 7: Saves the script entered in the script input zone.

  • 8: Activates the script debug mode. In this mode, the script input zone is not cleared when a script is run.

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

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:

  • 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.

modeler_fig_97.gif (91.4 KB) admin admin, 05 September 2012 11:04

modeler_fig_93.gif (108 KB) admin admin, 05 September 2012 11:04

save_as_macro.gif (999 Bytes) admin admin, 05 September 2012 11:04

run_script.gif (892 Bytes) admin admin, 05 September 2012 11:04

modeler_fig_98.gif (87.8 KB) admin admin, 05 September 2012 11:04

script_debug.gif (1006 Bytes) admin admin, 05 September 2012 11:04

open_run_script.gif (932 Bytes) admin admin, 05 September 2012 11:04

modeler_fig_96.gif (60.7 KB) admin admin, 05 September 2012 11:04

modeler_fig_95.gif (48.4 KB) admin admin, 05 September 2012 11:04

modeler_fig_99.gif (38.3 KB) admin admin, 05 September 2012 11:04

script_clear_output.gif (895 Bytes) admin admin, 05 September 2012 11:04

open_script.gif (916 Bytes) admin admin, 05 September 2012 11:04