Conditional

Route data flow based on a boolean condition.

What it does

Conditional picks between two values based on a boolean condition, a graph-native if/then/else. The condition is evaluated once and applied the same way to every channel. Any non-zero number, non-empty string, non-empty list or true boolean counts as true; zero, empty or false counts as false.

One condition can drive up to 8 independent channels. Raise Channels to add more if-true / if-false pairs, each with its own result output. Each channel passes whatever it is fed through as-is: an image stays an image, a list of points stays a list of points, with no resampling or reshaping.

When to use it

ParameterTypeDefault
conditionAny
channelsNumber1
if_true_0Any
if_false_0Any
if_true_1Any
if_false_1Any
if_true_2Any
if_false_2Any
if_true_3Any
if_false_3Any
if_true_4Any
if_false_4Any
if_true_5Any
if_false_5Any
if_true_6Any
if_false_6Any
if_true_7Any
if_false_7Any

Gotchas

Only the first channel's Result is always present. Result 1 and beyond appear once Channels is raised, so set it to the number of pairs in use.

An unconnected branch reads as 0, or the equivalent empty value for its type, not as unset. Wire both the true and false side of a channel to avoid a silent zero.

Both branches of a channel should carry the same kind of value. Where they differ, the true branch's type wins for the result.

Worked example

  1. Add a Conditional node and wire a boolean or a Compare result into Condition.

  2. Wire the two candidate values into If True and If False for channel 0.

  3. Connect Result to whatever should receive the chosen value.

  4. To switch more than one thing at once, raise Channels, fill in the new If True / If False pair(s) and take their Result output.

See also

Compare · Logic · Router · Automatic conversion