Write a rule on a parameter — gull system handbook

Step 3 Rules in gull system: picking a parameter, the rule editor in Properties, the live preview on the model, Evaluation, rules without a target, the Formulas / Code switch.

Write a rule on a parameter

A rule is a formula on one captured parameter: from what the customer entered it computes what is written into the model. It is written in step 3 in Properties and saves itself as soon as it is valid.

Procedure

  1. Open step 3 Rules. On the left is the tree of captured parameters from step 1 with a Rule column; a parameter that already has a rule carries the Set tag.
  2. Click a parameter. On the right, Properties shows its rows — Rule for a dimension, Suppression and Configuration for a component, Colour, Texture and Texture rotation (°) for an appearance.
  3. Write the rule. Refer to an input by its name, `[Bed length]`, to a function by name, `IF(…)`. The editor suggests as you type; Ctrl+Space reopens the suggestions. What a rule must return for each parameter type is in What a rule must return.
  4. Watch the editor's colour. Green = valid, red = an error, with the text under the editor. A red rule is never saved; a green one saves itself as soon as the app accepts it. There is no Save button here.
  5. Check the result on the model. About 0.4 s after you stop typing, the rule is evaluated with the inputs' defaults and the result is written into the open model in SOLIDWORKS. Merely clicking a row in the tree does not change the model.

The bar above the editor

Right-click in the editor offers Extract variable (Ctrl+E) — the selected part of the formula becomes a named variable — and Find all references to the name under the cursor.

Rules without a target

A rule whose parameter is no longer captured appears under Rules without a target and fails on every order. Either capture the parameter again under the same name, or delete the rule with Delete rule. Otherwise a rule is deleted by emptying its editor.

Formulas or Code

The ribbon's Evaluation group has the switch Formulas (one rule per parameter, like Excel) and Code (one script for the whole configurator, the Logic add-on). Switching asks "Change how rules are evaluated?"; the other mode stays saved and is simply not used. Code is described in Code mode: one script.

A rule does not read the model's current value. It reads inputs, variables, constants and tables; a captured parameter is the target it writes into. If you need a value from the model, make it an input with a default.