Nodes/ComfyUI-ZML-Image/ZML_任意开关-五V2
ComfyUI Node

ZML_任意开关-五V2

Type '1,2,4' and only those branches survive

By zml-w·Created about a year ago·Updated 2 months ago· 218
ZML_任意开关-五V2
  • 输入1
  • 输入2
  • 输入3
  • 输入4
  • 输入5
  • 输出1
  • 输出2
  • 输出3
  • 输出4
  • 输出5
索引判断1
False处理方式空值

Five toggle switches are fine until you want "outputs 1, 2, and 4" - then you're clicking three widgets instead of typing three characters. ZML_AnyTypeSwitchFiveBooleanV2 (ZML_任意开关-五V2) replaces the five booleans with a single text field: type 1,2,4 and those inputs pass through to their outputs. It's the same five-gate node as the V1, just with a type-in-the-list control, plus one genuinely useful extra: a switch for what happens when a selected branch has nothing to deliver.

What it is

Where V1 gives you five explicit toggles, V2 gives you 索引判断 (STRING, default "1") - a comma-separated list of which outputs to enable, parsed at runtime. Type 3 for just output 3, 1,2,4 for three at once. Values outside 1–5 are ignored, and invalid entries don't crash it, they just don't match anything. The all-optional any-type inputs (输入1 … 输入5) stay the same, as do the five 输出1 … 输出5 outputs.

The new input that matters is False处理方式 (how to handle "off"), with two choices:

  • 空值 (empty/null) - an off output emits nothing; downstream nodes receive None and do whatever they do with it.
  • 不执行下游节点 (don't execute downstream) - the off branches get an ExecutionBlocker, ComfyUI's mechanism for deliberately halting a branch of the graph. The downstream nodes connected to an off output simply never run, which is the difference between "there's nothing here" and "nothing here, so don't even try."

That second mode is the reason to pick V2 over V1 for automation: it turns the node from a data filter into a real execution gate.

How it works

The node parses the index string, validates it, and uses lazy evaluation to only request the input keys whose indices are listed. It's OUTPUT_NODE = True, so like the V1 it anchors execution and lets ComfyUI walk the graph backward from it. The ExecutionBlocker in the "don't execute downstream" mode is the same trick the pack uses in its image classification node - a branch that exists but is told not to run.

Install and gotchas

The standard pack ritual:

cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image

or ComfyUI Manager → ComfyUI-ZML-Image, then restart.

Where people get burned: a typo. 1,2, 4 (space) parses fine since entries are stripped, but 1 2 4 without commas parses as one invalid entry and enables nothing - the node doesn't tell you it matched zero. And the default index is "1", so if you were expecting all five to flow and you don't touch the field, only input 1 comes through. It's a Chinese-first UI like the rest of the pack; the translation patch at github.com/zml-w/ZZZ_ZML_English_Patch covers the mode dropdown. Small, well-scoped node, one-person pack - issues go to GitHub, because this thing has no English community to consult.

Categoryimage/ZML_图像/逻辑

Inputs (7)

NameTypeDefaultDescription
索引判断STRING1
False处理方式COMBO空值2 options: 空值, 不执行下游节点
输入1opt*
输入2opt*
输入3opt*
输入4opt*
输入5opt*

Outputs (5)

NameTypeDescription
输出1*
输出2*
输出3*
输出4*
输出5*