Page tree

MagicDraw 19.0 LTR SP3 Documentation

You can add a new macro and enter all necessary information about it in MagicDraw by following the steps described in Opening Macro Information Dialog and Adding a Macro and Its Information below.

On this page

Opening Macro Information Dialog

You can add or modify macro information such as the macro name and description, in the Macro Information dialog. To open the Macro Information dialog, you need to open the Organize Macros dialog first.

To open the Organize Macros dialog

  • Click Tools > Macros > Organize Macros on the MagicDraw main menu. The Organize Macros dialog will open, see figures below.

Organize Macros Menu


Organize macros dialog


To open the Macro Information dialog

  1. Click Tools > Macros > Organize Macros on the MagicDraw main menu to open the Organize Macros dialog, see above figure.
  2. Click . The Macro Information dialog will open.

Adding a Macro and Its Information

Use the  or  button in the Organize Macros dialog to add or edit a macro and its information in the Macro Information dialog. You can also press the mnemonic keys to add or edit a macro, see  Macro Information Dialog Mnemonic Keys.


To add a macro and enter macro information in the Macro Information dialog

  1. Open the Organize Macros dialog (click Tools > Macros > Organize Macros  on the MagicDraw main menu).
  2. Click . The Macro Information dialog will open, see figure below.

    The , and  buttons in the Organize Macros dialog will be disabled if there is no macro in the macro table or if you do not select any macro from the table.


    The Macro Information Dialog

  3. Type the macro name in the Name box.
  4. The default macro language you have previously selected (see Selecting a Default Macro Language) will appear in the Macro Language box.
  5. Click the button, to locate a macro file. The Open file dialog will open, see figure below.
  6. Select the file and its type (there are 5 types of file filter: *.bsh*.groovy*.rb*.js, or *.py), see figure below.

    Use Path Variables Checkbox

  7. Click Open, see figure above. The selected pathname will appear in the File box in the Macro Information dialog, see figure below.

    Types of File Filter

    Macro Information Dialog

  8. Select either (i) the Use path variables check box or (ii) the Add macro to model check box.

    • If you have specified the file or network path in the Environment Options dialog by clicking Options > Environment > Path Variables and selected the  check box in Macro Information dialog, the <Path Variable name> will show in front of the file pathname. This field is the [Required] field, for example, <mypath>/<macro_name>.js.
    • If you select the  check box, the full pathname will not be saved.
    • If you select the  check box, your source code will be imported from the file to the model. The location to keep the model is Data::MacroEngine.
    • You can open the Macro Information by using Ctrl+Alt+m as a shortcut key.
  9. Type the macro description in the Description box, see figure above.

    A macro name must be unique and cannot be duplicated.

  10. The function of the  check box is to allow you to run the default values automatically. If you select the check box, the system will not open a dialog to prompt you to input the value.

    If you select the  check box, you need to enter the valid default value of each parameter.

  11. Click Add to specify the arguments of the macro. The arguments specified in the Arguments table will be the global variables of a specific macro.

    • Name column contains the name of a parameter
    • Type column contains the type of a parameter
    • Array check box is to identify if an array is the parameter
    • Null check box is to identify if null is the parameter value
    • Default Value column contains an initial value to run the macro

    • A parameter type can be a String, Integer, Long, Double, Date, or ElementPath.
    • If the Null check box is selected, you cannot enter the default value of that particular parameter.
    • An empty value in the Default Value column does not necessarily mean a null value, for example an empty string value is an empty string.
    • If you input an invalid default value or you do not enter the argument name, the system will display the following error message when you run the script: The following argument(s) are invalid: <List of the invalid argument>.
  12. Type a keyboard shortcut that will be used to run the macro in the box and click . The newly assigned keyboard shortcut will appear in the Current keys box.
  13. Click OK. The Organize Macros dialog will open, showing the newly added macro name, description, and keyboard shortcut.

    • Macro names, filenames, and languages are required.
    • Macro description and keyboard shortcuts are optional.
    • If any of the required fields are not entered or duplicate macro name is entered, the following message will open: The following field(s) are invalid: <List of the problems>.
    • If the  check box is selected and at least one value is empty or not valid, then the following error message will open: The following value(s) are invalid. <List of the invalid value>
    • If the  check box is selected, all variables must have valid values or are set to null.
  14. Click  to close the Organize Macros dialog.

Editing Macro Information

You can see macro information such as names and descriptions, as well as the macro keyboard shortcuts in the Organize Macros dialog.


To edit macro information

  1. Click Tools > Macros > Organize Macros. The Organize Macros dialog will open, see figure below.

Editing a Macro

      2.  Select a macro from the table and either click Edit or press Alt + E. The Macro Information dialog will open.

      3.  Edit the macro information.

      4.  Click OK to save it. You will see the altered information in the Organize Macros dialog.

      5.  Click .

Macro Information Dialog Mnemonic Keys

Macro Engine provides mnemonic keys for you to perform some operations, for example, highlight a textbox and click a specific button in the Macro Information dialog. The table below lists the Macro Information dialog mnemonic keys and their function.

Table listing of Macro Information Dialog Mnemonic Keys

Mnemonic keys
Alt + NTo place the pointer in the 
Alt + MTo highlight the
Alt + FTo place the pointer in the 

Alt + .To open the File dialog.
Alt + DTo place the pointer in the 

Alt + ATo add an argument in the Arguments 

Alt + lTo delete an argument in the Arguments area.
Alt + UTo highlight the Current keys

Alt + GTo click the 

Alt + RTo click the

Alt + ETo click the 

Alt + PTo place the pointer in the

Alt + OTo click the 

Alt + CTo click the 

Alt + HTo click the 



  • No labels