Connecting Modules with Options & MVL -Modular Variant
The bicycle example will be referred in this post while discussing Options & MVL.
Options & Values
For modular variant, options can be created with visibility of private & public. Options can be defined with following types:
- String
- Integer
- Real
- Logical(true, false)
New options can be created by clicking on button in variant data pane. Options can be created through New Option Wizard or through Create New Option dialog by clicking on second radio button in the wizard.
Options can also be defined as global option or external option.
Global Option
When there are number of options to be created in modules with almost same set of allowed values, global options can be used. Global option is defined on an item (standalone module) with fixed allowed values. This option can then be referenced in a module to be reused. More allowed values can be added to options referencing this global option. Click on Tools→Variants→Set/Unset Global Option Item to define global option on an item. This updates the preference PSM_global_option_item_ids preference by adding the item ID.
External Option
External option is defined on top level module. This is a global option for which fixed allowed values cannot be changed. All the options in the modules referencing this external option will have the same value.
To create external option:
- Select ‘The same type and restrictions as an existing option’ radio button in ‘Option type’ step of New Option Wizard.
- Select ‘Search for Existing Options’, in ‘Derived Option Type’ step of the wizard.
Selecting the external option checkbox will use this selected option as external option for the new option created.
To verify if the option created uses external option, launch the ‘Edit option’ dialog box.
Mostly, external option is referenced from global option. In this case to propagate option value, it is not necessary to create linking (mapping) explicitly between the modules. External option value is automatically propagated to child module options referencing it .So, in example above if external option sets the approved standard to ‘ISO’ then wheel, cassette and crankset approved standard will be set to ISO automatically.
Presenting Child Options
Options of child modules should be presented to parent, so that it appears as public option of parent module. Select the parent module and click on button in variant data pane.
In data pane:
Child Module Constraints
This function is used to propagate the parent option to the child module options. Hence mapping is required between child option and the corresponding parent option (parent option that is getting propagated down in child modules).
Select the child module and click on Child Constraints button to display Constraints dialog. Options of all child modules is listed in Option dropdown. Select ‘to option’ radio button to map child option to parent option.
Mapping is as shown in data pane under Child Module Constraints.
Module Option Constraints
Constraints dialog is used for multi-functionality. It can be used to set/fix default value for an option and also to set value for private option based on public option. Click on button to create new Internal Modular Constraints.
Set/Fix default value
Options default value can be set with Constraints dialog. When type is selected as ‘fix’, default value cannot be overridden by users while configuring structure.
Set value for private options
Value of private option can be set by setting conditions on public options. The condition section in the Constraints dialog is used. To define more complicated conditions, MVL(modular variant language) is used instead.
Error Check
As discussed in last post, rear wheel of bicycle is not recommended to be bigger than front wheel. So, for this invalid configuration, error check should be created to warn user of unsupported configuration. Depending on the severity of invalid configuration, message displayed can be warning, error or information. Select the module and click on button to create error check.
In data pane:
Variant Condition
Variant Condition is created on occurrence to control the conditions under which, the occurrence will be loaded in the structure. Click on Edit Variant Condition to display the variant condition dialog.
Any number of conditions can be created in this dialog .Only options of immediate `parent module is included to set variant condition for an occurrence.
Setting any complicated conditions cannot be done in the dialog. It has to be done through MVL (modular variants language)
Modular Variant Language (MVL)
The complex conditions that cannot be created or edited in user interface (Variant condition dialog or Constraints dialog or Error dialog) has to be created in modular variant language that represent the condition in expert mode. Editing the expression in expert mode, marks the module as Expert module and it cannot be maintained by regular user interface.
Select the child module and under Constraints node in Variant pane, double- click Complex Constraints to create or edit complex condition.
Expression can be created in the shown editor.
Precedence in MVL
In a module, expressions can be created with MVL for following elements:
Expressions should be created in listed order of elements above. If in MVL editor, this order is not maintained, variants configured will not be as expected. So, expressions to check error on option should be listed first in MVL editor .Expressions to set private option or to set/fix default value for an option will be next.
For Internal Module Constraint & Child Module Constraint, there can be instances when expressions sets value of an option in more than one way. A default value may be different from set value for the same option. Expression evaluation in such cases will be in following order starting from least priority to highest priority.
- Default
- User Set
- Set
- User Fix
- Fix
- External
- Variant Item
Example:
public 'Number of Chainrings' integer=1, 2, 3 default 2 - default value if BD10012:'Number of gears' =<10 then set BD10012:'Number of Chainrings' to 1 - set value
If Number of gears is 6, Number of Chainrings will be 1 and not 2
MVL Conventions
- MVL is case sensitive
- White space is ignored except that contained in double quotes.
- Text appearing inside [ ] is optional
- Lines preceded with a # character contain comments.
- Single quotation marks are required for some identifiers (IDs) and double quotes are used for string values. E.g. set BD10012: ‘Cassette Material’ to “steel”
To create complex conditions, expert mode editor includes the Intellisense autocompletion feature. While typing new constraint or expression, editor displays the dialog box with suggestions for what to type next.
Example of MVL expressions
To set Number of Cogs in the gear assembly of bicycle:
- User cannot enter gear number 11, 13, 17,19,23,29 and is handled with error check in parent module:
- Number of cogs has to be integer, so for gear = 15 chainrings cannot be set to 2, but the gear number is possible. Hence, number of chainrings should be 3 in this case.
Value for Number of Chainrings and Number of Cogs are calculated with expressions:
Also Read:
Classic Variant Configuration in Structure Manager
Configure Classic Variants with Variant Rule
Difference between Classic & Modular Variants
Revision Effectivity & Nested Effectivity
Occurrence Effectivity in Teamcenter