For concreteness it is easiest to go through the process of building and using a macro step by step. We will reproduce the SMTH1 Builtin for this example.
For more information on macros see Working with Macros.
From the Model menu select the Macro Manager item:
The Macro Manager will appear:
Click on to add a new macro:
Then click on to edit the new macro. You will enter the macro editor, which is just the model window with the Macro Settings Tab open instead of the regular model settings.
Build out the following structure. Note that the stock should be allowed to go negative and the flow should be a biflow:
The use of the STEP function allows us to see the response of our macro to a step input. Behavior will be displayed as you edit the macro to make it easier to see if any issues remain. Because input will be a required input, its equation is not important.
Now click on a blank part of the model area to open the Macro Settings panel, rename the macro to MySmooth, choose MySmooth as the output and choose input, smoothing_time and initial as the inputs, making initial optional. This can be done following the directions in Macro Settings Tab. The panel should look like:
Notice that the macro name matches the name of the variable used as its output. Though this is not required, it is a fairly common way to define macros and should make future editing easier. Notice also that the input and output markings on the diagram have changed:
This is consistent with module input and output markings, but initial is marked as an input even though it has a connection from input. This is because initial will be replaced with argument if MySmooth is used with 3 arguments, but will use the existing equation (and connection) if MySmooth is used with 2 arguments.
To exit macro editing and return to the model proper simply click on the button in the Mode toolbar at the top.
To use the macro we create a variable and give it an equation with the macro. For example
MySmooth(STEP(10, 4), 4, 6)
will give behavior of:
Here both the user definition and the builtin SMTH1 are used, and produce the same results (MySmooth really is the same as SMTH1).
Notice that you can start typing in the macro name and autocomplete will fill in the rest. You can also hover over the name to see the arguments. These will match the variable names you used as arguments.