Beginner Tutorial Macro Macro modules Global Macro

Example 2.2: Global macro modules

Introduction

In this chapter you will learn how to create global macro modules. There are many ways to do this. You can convert local macros into global macro modules or you can directly create global macro modules using the Project Wizard. In contrast to local macro modules, global macro modules are commonly available throughout projects and can be found via module search and under [ Modules ].

Steps to do

Transform a local macro module into a global macro module

To transform our local macro module Filter from Chapter I into a global macro module, right-click Right Mouse Button the macro module to open the context menu and select [ Extras → Convert To Global Module... ]

Convert local macro to global macro

Convert local macro to global macro

Define module properties

  1. Choose a unique module name

  2. State the module author

  3. Select the genre of the module. For this, browse through the module genres to select the appropriate genre. In our case, as our macro module contains a contour filter, we will choose the genre Filters.

    The Genre defines the location where your module will be shown in MeVisLab [ Modules ] menu.

  4. Tick the box Add reference to example network to directly create the template for an example network for your macro module.

  5. Select the package you like to store the module in. We choose the package we created before. Your module is saved in an .mlab format and can be found in \MyPackageGroup\General\Modules\Macros\MyProject.

Create global macro module

Create global macro module

Use the Project Wizard to create global macro modules

Instead of converting a local macro module into a global macro module, you can also use the Project Wizard to create new macro modules. Open the Project Wizard via [ File → Run Project Wizard ... ]. Then, select [ Modules (Scripting) → Macro module ] and Run Wizard.

Define module properties

  1. Choose a unique module name

  2. State the module author

  3. Select the genre of the module. For this, browse through the module genres to select the appropriate genre. In our case, as our macro module contains a contour filter, we will choose the genre Filters.

  4. Tick the box Add reference to example network to directly create the template for an example network for your macro module.

  5. Select the package you like to store the module in. We choose the package we created before. Your module is saved in an .mlab format and can be found in \MyPackageGroup\General\Modules\Macros\MyProject.

Press Next > to edit further properties. You have the opportunity to directly define the internal network of the macro module, for example by copying an existing network. In this case, we could copy the network of the local macro module Filter we already created. In addition, you have the opportunity to directly create a Python file. Python scripting can be used for the implementation of module interactions and other module functionalities. More information about Python scripting can be found here.

ProjectWizard1

ProjectWizard1

ProjectWizard2

ProjectWizard2

Structure of global macro modules

After creating your global macro module, you can find the created project MyProject in your package. This project contains your macro module Filter. For the macro module exist three files:

  • Filter.def: Module definition file
  • Filter.mlab: Network file which contains the internal network of your macro module
  • Filter.script: MDL script file, which defines in- and outputs of your macro module as well as fields. This file defines the module panel, as well as references to python scripts.

In addition, two folders may be created:

  • mhelp: contains the help files of all modules of this project
  • network: contains the example networks of all modules of this project

Structure of global macro modules

Structure of global macro modules

How to find global macro modules

All available modules are categorized and can be found via [ Modules ] in the respective genre. After creating a global macro, the new module can be found via [ Modules → Filters ]. In addition, you can now find your macro module via module search.

Find module in menu

Find module in menu

Summary

  • Via right-click Right Mouse Button [ Extras → Convert To Global Module... ] global macro modules can be created out of local macro modules
  • You can use the Project Wizard to create new macro modules
  • You need to have a package structure to store your global macro module
  • Global macro modules are available throughout projects and can be found via Module Search and under menu item [ Modules ].