Creating and Editing Variable Selections

You can create and edit variable selections. A variable selection consists of one variable selection definition and one or several rules.

In this scenario you create and edit some variable selections. The underlying annotations and code, including examples and simulation results, is described in About Variable Selections. There is also a tip how to further decrease the output file size.

Note: You can create variable selections from pinned variables and plotted variables. See Saving Monitored and Plotted Variables as Variable Selections.

This task shows you how to:

Create a Variable Selection Definition

You can create empty variable selection definitions, to later add rules.

  1. From the Behavior Authoring section of the action bar, click Variable Selections .
    The Variable Selections dialog box appears.
  2. In the Variable Selections dialog box, click Add Selection.
    The Variable Selection Definition dialog box appears.
  3. In the Variable Selection Definition dialog box:
    1. In the Name of variable selection box, enter the name of the variable selection definition, in this scenario enter MyVariableSelection.
    2. Optional: In the Comment (optional) box, enter a comment or description of the variable selection definition.
    3. To let this variable selection override selections with the same name found on lower hierarchical levels, activate Override variable selections in base classes.

      By default, this option is activated.

    4. Do any of the following.

      • Click OK to create the variable selection definition and close the dialog box.
      • Add rules to the variable selection by clicking Add Rule. See next subtask.

Add Rules to a Variable Selection

You can add rules to a variable selection definition. There are rules for matching variables, but also for how to present the result in the Variable Browser.

Important:
  • To finish creating or editing a rule, you must always click Next > to be able to click Finish even if you donĀ“t intend to change anything in the section New section for the variable browser.
  • You can use wildcards, for example "*" in the boxes.
  • Variable selection using predefined tags are not covered by the variable selection dialog, you must work with Modelica text to create such selections. See Tags.

Before you begin: You have defined at least one variable selection.
  1. If the Variable Selections dialog box is not already displayed, from the Behavior Authoring section of the action bar, click Variable Selections .
    The Variable Selections dialog box appears.
  2. Click a variable selection.
  3. To add a rule to it, click Add Rule.
    The Rules for Matching section appears.
  4. In this section, do the following:
    1. In the Variable name boxes, enter one or two variable names to match.

      If you want to match more variables, add new rules.

      Note: To create examples in Examples:
      • Enter, in the first box, phi, click Next > and then Finish to create Example 1.
      • Enter, in the first box, phi, and, in the second box tau, then click Next > and then Finish to create Example 2a.

    2. To limit the selection to specified components, activate In one of these components and, in the boxes, enter one or two components.

      If you want to match more components, add new rules.

    3. To limit the selection to component of specific classes, activate When the model of the component is and enter the class by typing or use Browse.

      If you click Browse you can select from the available packages, and you have search possibility.

      Tip: To create Example 3:
      1. Set the variable name to phi (Step 4a).
      2. Activate When the model of the component is.
      3. Browse for any flange class, for example, Modelica.Mechanics.Rotational.Interfaces.Flange_a.
      4. Change the last part of the string to Flange*
      5. Click Next >.
      6. Click Finish.

    4. To limit the search to also matching variable descriptions, activate And when the variable description matches and enter the description string to match.
    5. Click Next >
      A section that enables you to create new sections in the Variable Browser appears.
    6. To create an additional heading, activate Additional heading and type the heading.
    7. To include the path in the new section, activate Variable path.

      To create Example 5:

      1. Set the variable name to phi (Step 4a).
      2. Activate Variable path.

      To create Example 6:

      1. Create one selection with the following rule:
        1. Set the variable name to phi (Step 4a).
        2. Click Next >.
        3. Activate Additional heading and enter the name Angles.
        4. Activate Variable path.
        5. Click Finish.
      2. Add a new rule to the selection. To create the rule:
        1. Set the variable name to tau.
        2. Click Next >.
        3. Activate Additional heading and enter the name Torques.
        4. Activate Variable path.
        5. Click Finish.

    8. Click Finish.

Edit a Variable Selection Definition or a Rule

You can edit variable selection definitions and rules.

Before you begin: You have defined at least one variable selection.
  1. If the Variable Selections dialog box is not already displayed, from the Behavior Authoring section of the action bar, click Variable Selections .
    The Variable Selections dialog box appears.
  2. To edit a variable selection definition, click the definition and then click Edit
    The Variable Selections dialog box appears to let you edit the present definition the same way you created it. See the first task above for the editing.
  3. To edit a rule, click the rule and then click Edit
    The Rules for Matching dialog box appears to let you edit the present rule the same way you created it. See the task above for the editing.
  4. To delete a variable selection or a rule, click and then click Delete.