You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: mevislab.github.io/content/tutorials/basicmechanisms/macromodules.md
+17-14Lines changed: 17 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: "Example 2: Macro modules and Module Interaction"
3
-
date: 19-05-2025
3
+
date: 2025-05-19
4
4
draft: false
5
5
weight: 370
6
6
status: "OK"
@@ -18,12 +18,13 @@ menu:
18
18
## Macro Module
19
19
A macro module can be used to develop your own functionality in MeVisLab. You have two main options for how to use it:
20
20
21
-
***With Internal Networks**: Use a macro module to reuse a network of modules. For example, if you build a network that applies a specific image filter and you want to use this setup in multiple projects, you can wrap the entire network into a single macro module. This way, you don’t need to manually reconnect all the individual modules each time — you just use your macro module.You can see in the left side of the image is the Internal network. You can see an example in [Basic Mechanics of MeVisLab (Example: Building a Contour Filter)](/tutorials/basicmechanisms#TutorialMacroModules).
21
+
***With Internal Networks**: Use a macro module to reuse a network of modules. For example, if you build a network that applies a specific image filter and you want to use this setup in multiple projects, you can wrap the entire network into a single macro module. This way, you don’t need to manually reconnect all the individual modules each time — you just use your macro module.You can see the internal network at the left side of the image below. You can see an example in [Basic Mechanics of MeVisLab (Example: Building a Contour Filter)](/tutorials/basicmechanisms#TutorialMacroModules).
22
22
23
23
***Without Internal Networks**: Use a macro module to add your own Python code. If MeVisLab is missing a specific functionality, you can write your own Python script and include it in a macro module.
24
-
This allows you to extend the software with custom behavior that integrates smoothly into your project. You can see the right side of the image the python code.
24
+
This allows you to extend the software with custom behavior that integrates smoothly into your project. You can see the Python code at the right side of the image.
25
25
26
-
The figure below is a Macro Module with Internal Processing and Python Interaction:
26
+
27
+
You can combine both approaches: have a macro module containing a module network, and additionally Python code to add your own logic or functionality:
27
28
28
29

29
30
@@ -40,7 +41,7 @@ It takes an existing network of modules or Python code. To the user, interacting
40
41
***Implementation:**
41
42
Macro modules are primarily defined using the MeVisLab Definition Language (MDL) and often incorporate Python scripting for more dynamic behavior. You don't need to write C++ code to create a macro module.
42
43
***User Interface:**
43
-
You can define your own User Interface for macro modules.
44
+
You can define your own User Interface for macro modules using MDL.
44
45
***Scope:**
45
46
Macro modules can be either global (available in all your MeVisLab projects) or local (specific to the current network you are working on).
46
47
@@ -59,24 +60,24 @@ A Local Macro in MeVisLab is a macro module that exists only within the context
59
60
* A global macro is listed in the Modules panel and module search.
60
61
61
62
{{<alertclass="info"caption="Info">}}
62
-
Packages are the way MeVisLab organizes different development projects. You can organize zour own modules, test cases or C++ modules in a package.
63
+
Packages are the way MeVisLab organizes different development projects. You can organize your own modules, test cases or C++ modules in a package.
63
64
{{</alert>}}
64
65
65
66
### Inputs, Outputs, and Fields:
66
-
You can addd inputs and outputs to your macro module to connect it with the other modules:
67
+
You can add inputs and outputs to your macro module to connect it with the other modules:
67
68
***Inputs:** These are connection points through which the module receives data from other modules. You define inputs in the *\*.script* file using the Input keyword. You can also define the type for each input.
68
69
***Outputs:** These are connection points through which the module sends processed data to other modules. You define outputs in the *\*.script* file using the Output keyword. You can also define the type for each output.
69
70
70
-
You can also add fields to your macro module. Fields allow you to change parameters for your module or to see the values of results. Fields can also be added to the panel of the macro module so that the user can change them.
71
-
***Fields:** These are parameters that control the module's behavior, typically visible in the modules panel or in the Module Inspector. You define fields in the *\*.script* file using the Field keyword, specifying the data type, default value, and other properties.
72
-
The below figure shows the input , outoutand feilds :
71
+
You can add fields to your macro module. Fields allow you to change parameters for your module or to see the values of results. Fields can also be added to the panel of the macro module so that the user can change them.
72
+
***Fields:** These are parameters that control the module's behavior, typically visible in the module's panel or in the Module Inspector. You define fields in the *\*.script* file using the Field keyword, specifying the data type, default value, and other properties.
73
+
The below figure shows the input, output and fields:
73
74

74
75
75
76
### Files Associated with a Macro Module:
76
77
Macro modules typically contain the following files:
77
-
***Definition file (*\*.def*):** The module definition file contains the definition and information about the module like name, author, package, etc. **Defintion files are only available for global macro modules**.
78
+
***Definition file (*\*.def*):** The module definition file contains the definition and information about the module like name, author, package, etc. **Definition files are only available for global macro modules**.
78
79
79
-
***Script file (*\*.script*):** The script file defines inputs, outputs, fields and the user interface of the macro module. In case you want to add Python code, it includes the reference to the Python script file. The *\*.script* file allows you to define Python functions to be called for multiple situations.
80
+
***Script file (*\*.script*):** The script file defines inputs, outputs, fields and the user interface of the macro module. In case you want to add Python code, it includes the reference to the Python script file. The *\*.script* file allows you to define Python functions to be called on field changes and user interactions.
80
81
81
82
***Module Initialization**: You can add the *initCommand* to the *Commands* section and the given Python function is called whenever the module is added to the workspace or reloaded.
82
83
***Window creation**: You can add the *initCommand* to the *Window* section and the given Python function is called whenever the panel of the module is opened.
@@ -107,12 +108,14 @@ For an example see [Example 2.5.2: Module interactions via Python scripting](/tu
107
108
108
109
* Files
109
110
* (*\*.script*): Defines inputs, outputs, fields, and user interface.
110
-
* (*\*.py*): Optional, contains Python code.
111
+
* (*\*.py*): Contains Python code.
111
112
* (*\*.def*): Definition file (only for global macros).
113
+
* (*\*.mlab*): Stores the internal network of modules within the macro module.
114
+
* (*\*.mhelp*): Provides documentation or user assistance for the module.
112
115
113
116
* Components
114
117
* Inputs/Outputs: For connecting the module with other modules.
115
118
* Fields: Parameters for user control
116
119
* Field Listeners: Run Python code when a field value changes
117
120
118
-
*Package: are the way MeVisLab organizes different development projects. Required for global macros.
121
+
*Packages: are the way MeVisLab organizes different development projects. Required for global macros.
0 commit comments