Nodes/ComfyUI Easy Use/easy anythingIndexSwitch
ComfyUI Node Runs on cloud

easy anythingIndexSwitch

Pick input number N by index

By yolain·Created 3 years ago·Updated 8 days ago· 2,633
easy anythingIndexSwitch
  • value0
  • value1
  • value2
  • value3
  • value4
  • value5
  • value6
  • value7
  • value8
  • value9
  • value10
  • value11
  • value12
  • value13
  • value14
  • value15
  • value16
  • value17
  • value18
  • value19
  • value
index0

A multi-way selector. You give it a bunch of values and a number, and it passes through the one at that number. Index 0 outputs value0, index 3 outputs value3, and so on. Where easy ifElse is a two-way fork, this is the ten-plus-way version - a rotary dial for your graph.

Why you'd reach for it

The obvious use is a manual chooser: wire five checkpoints, or five prompts, or five upscale models into it, and select which one drives the run by setting a single number. No rewiring between experiments - just change the index. That alone makes it handy for A/B/C/D testing without dragging noodles around.

The far more powerful use is driving the index from something else. Because index is an integer input, you can compute it. Wire a loop counter in and each iteration selects the next value automatically - pass 1 on the first loop, pass 2 on the second, cycling through a set of prompts or settings. Combine it with easy mathInt (to derive the index) or a for-loop's index output and you've built a lookup table: "on step N, use setting N." That's the pattern that turns a static graph into one that varies itself across a batch.

It lives in the EasyUse/Logic family alongside the if/else and the for-loops, and it's usually working next to them.

The inputs and outputs

  • index (INT, 0-9) - which input to pass through. Set it by hand or drive it from an upstream node.
  • value0 … value19 (each any type, all optional) - the candidate values. Connect as many as you need; you don't have to fill them all. The index picks which connected slot gets forwarded.
  • The single value output (any type) - the selected input, passed through with its original type intact.

One thing to hold onto: the input slots go up to value19, but the index widget itself tops out at 9, so plan your indexing around that if you're selecting by hand.

Installing it

ComfyUI Manager: search ComfyUI Easy Use, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/yolain/ComfyUI-Easy-Use

then install the requirements (install.bat on Windows, else pip install -r ComfyUI-Easy-Use/requirements.txt) and restart.

Common issues

  • Off-by-one. The switch is zero-indexed - value0 is the first slot. If you set index to 1 expecting the first input, you'll get the second. This is the single most common stumble; when the wrong thing comes out, check whether you're counting from 0 or 1.
  • Pointing at an empty slot. If the index lands on a slot you never connected, there's nothing to pass through. Make sure the index range you'll actually hit maps onto slots you've wired.
  • Mixed types. Since every slot is "any," it's on you to keep the ones you'll actually select consistent with what's downstream - feed the switch a mix of IMAGE and MODEL and you'll get a type error whenever it lands on the one your consumer can't use.
  • Older installs. The pack's changelog records a fix for anythingIndexSwitch failing in certain environments, so if it misbehaves, update Easy-Use before debugging further.
CategoryEasyUse/Logic/Index Switch

Inputs (21)

NameTypeDefaultDescription
indexINT00–9
value0opt*
value1opt*
value2opt*
value3opt*
value4opt*
value5opt*
value6opt*
value7opt*
value8opt*
value9opt*
value10opt*
value11opt*
value12opt*
value13opt*
value14opt*
value15opt*
value16opt*
value17opt*
value18opt*
value19opt*

Outputs (1)

NameTypeDescription
value*