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
the macro module to open the context menu and select [
Extras
→
Convert To Global Module...
]
Define module properties
Choose a unique module name
State the module author
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.
Tick the box Add reference to example network to directly create the template for an example network for your macro module.
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.
Make sure to chose Directory Structure as self-contained. This makes sure that all files of your module are stored in a single directory.
Also keep in mind that Python files are only created automatically if selected in the Project Wizard. Converting a local macro to a global macro does NOT create a Python file automatically.
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
Choose a unique module name
State the module author
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.
Tick the box Add reference to example network to directly create the template for an example network for your macro module.
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.
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
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.
Summary
- Via right-click [ 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 ].