Conditional

Run a different diagram for each condition. Create branches, define their ports, and wire them on the canvas.

A Conditional checks IF, then any ELIF branches, from top to bottom. Only the first matching branch runs. ELSE runs when none match. Use If-Then-Else when you only need to select between two already-computed signals.

Build a command gate

When enabled is true, pass command to result. Otherwise, output 0.

STEP 1 / 4Drag Conditional from the block library onto the canvas. Select it to open its properties.
Parent canvas
ConditionalIFIf branchtrueELSEElse branchStart with IF and ELSE
All steps in text
  1. Drag Conditional from the block library onto the canvas and select it.
  2. In Branches & ports, name IF Active and set its condition to enabled. Press Enter to save the condition. Add input command and output result, then choose Apply interface. Open ELSE, name it Fallback, and add output result. Apply this interface too.
  3. Double-click Active on the canvas. Connect the automatically created Virtual Input command to Virtual Output result. Return through the breadcrumb, open Fallback, and connect a Constant with value 0 to its result output. Use float64 for both result outputs and their connected values in this example.
  4. Return to the parent canvas. Connect a boolean signal to enabled on top, a numeric signal to command on the left, and take result from the right. Test both values of enabled: true passes the command; false returns zero.

Read the ports

  • Top — condition inputs. Typing enabled in the condition exposes a data input with that name. Connect a boolean signal for this example.
  • Left — branch inputs. Inputs are grouped by IF, ELIF, and ELSE. A port belongs to its labeled branch; identical names in different branches are separate connections.
  • Right — shared outputs. Both branches write to the same parent port, result. The selected branch decides its value.

Give branches the same outputs

For each shared output, use the same name, data type, and dimensions in every branch. The value can change; the output interface stays the same.

For the command gate, configure and wire:

BranchOutput nameType / shapeValue it supplies
IF · Activeresultfloat64, scalarThe incoming command
ELSE · Fallbackresultfloat64, scalarConstant 0

The parent canvas shows one result port. With command = 12, it outputs 12 when enabled and 0 otherwise.

  • Copy the output name exactly. result and fallback_result create two separate parent ports; they do not become alternatives for one output.
  • Match the connected values too. A scalar and a vector, or float64 and int32, cannot be merged as-is. Make the connected signals the same type and shape first; the output does not convert them for you.
  • Wire the output inside every branch, including ELSE. Adding its name creates the Virtual Output block; it does not connect it. A missing branch output is not an automatic zero. For a zero fallback, connect a Constant 0.

Branch inputs may differ: Active needs command; Fallback only needs its Constant.

Write a condition

Click the branch’s Condition field and enter one expression that answers true or false. Press Enter to save. ELSE has no editable condition; it is the fallback.

You want to checkWriteInputs to connect on top
A boolean signal is trueenabledenabled (bool)
A value exceeds a limitspeed > 10speed (numeric)
Two values are equalmode == 2mode (numeric in this example)
Both conditions holdenabled and speed > limitenabled (bool), speed and limit (numeric)
Either condition holdsspeed < 0 or speed > 100speed (numeric)
A boolean signal is falsenot faultfault (bool)
A calculated comparison holds(target - actual) * gain > 0.5target, actual, gain (numeric)

Allowed syntax: numbers (including -2, 0.5, 1e-3), true / false, input names, arithmetic + - * /, comparisons == != < <= > >=, boolean operators and or not, and parentheses. Use parentheses to make grouping explicit, such as enabled and (speed > 10 or override).

Where do the names come from?

Typing speed > limit exposes two condition inputs on the top of the Conditional. Connect the speed signal to speed and the threshold signal to limit. Names are case-sensitive; use letters, digits, and underscores, starting with a letter or underscore.

To use a parameter, feed it through a Constant block: set its value to your $parameter reference, connect it to the top limit input, then write speed > limit. Do not put $parameter directly in the condition. A branch input with the same name on the left is a separate port; wire the top input for the condition as well.

Common fixes

Instead ofUse
speed = 10speed == 10 — equality uses two equals signs
enabled && ready or !faultenabled and ready or not fault
speed when speed is numericspeed > 0 — numbers are not implicitly true or false
0 < speed < 100speed > 0 and speed < 100

Conditions do not support function calls such as abs(speed), strings, %, **, array indexing, or member access such as Mode.SPORT. Calculate those values with blocks first, then connect the result as a condition input.

“Valid” confirms the expression’s syntax. It does not confirm that every input is connected or correctly typed; those checks happen when the model is validated or built.

Add or edit branches

Choose + Add elif to insert another condition before ELSE. Order matters: the first true condition wins. An IF condition of true always selects IF, so later branches will never run.

Expand a branch to add, rename, or remove ports, then choose Apply interface. Modeloop updates the corresponding Virtual Input/Output blocks inside it. Child-side edits synchronize back to the parent too. When renaming a shared output, update its name in each branch so it remains one parent output.

Renaming a port preserves its wiring; removing it removes attached connections. Undo restores an applied interface edit. Collapsing a branch preserves unfinished port edits; Cancel discards them.