YCSwitch(any)
Pick one input, pass it through — a switch that handles any type
- input1
- selected_value
- selected_label
- selected_index
If you've used Impact Pack, ImpactSwitch is your mental model. YCSwitch is the same idea, ported into this pack: connect any number of inputs - input1, input2, and so on, slots appearing as you connect them - set select to an integer, and the node passes through only that input. Any type, no converting everything to strings first. It'll switch a MODEL, a CLIP, a prompt string, an image, whatever. That's its whole personality.
How it works
The secret sauce is the Impact Pack's AnyType trick: a string subclass whose __ne__ always returns False, so the frontend never rejects a wire as "wrong type." New input slots spawn lazily as you connect, and because the inputs are lazy, only the selected one actually gets evaluated - branches you don't pick don't run. select is 1-based, and the node also hands back the selected slot's label and its index.
- Inputs:
select(INT),sel_mode(BOOLEAN), andinput1throughinputN(ANY). - Outputs:
selected_value(ANY),selected_label(STRING),selected_index(INT).
The sel_mode toggle is the only thing that'll make you think: select_on_execution (default) chooses dynamically at run time; select_on_prompt resolves the choice before execution, which is the compatibility path for older ComfyUI versions that can't handle the dynamic behavior.
When you'd use it
A/B testing two prompts or two LoRA paths in one graph, routing around a broken branch without deleting it, or a single dial to flip between source images. It's a workhorse, not a party trick - the kind of node that quietly lives in a workflow and makes it feel like a real tool.
Two gotchas. If select points at a slot with nothing connected, you get None out and a log line - wire it before you switch it. And because lazy evaluation skips unselected branches, don't use it to "pre-warm" nodes you expect to run; anything downstream of an unselected branch simply doesn't execute.
Installing
Same pack, same two lines:
cd ComfyUI/custom_nodes
git clone https://github.com/yichengup/ComfyUI-YCNodes_Toolkit
Restart (or ComfyUI Manager → search "ComfyUI-YCNodes_Toolkit"). Only numpy and Pillow behind it, no models. If you already have Impact Pack installed you don't strictly need this node - but it's here, it works the same way, and it keeps your graph inside one pack.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| select | INT | 11–999999 | 选择要输出的输入编号 |
| sel_mode | BOOLEAN | false | select_on_execution 在执行时动态选择;select_on_prompt 兼容旧版 ComfyUI,在执行前确定。 |
| input1opt | * | 任意输入,连接后自动新增下一输入槽 |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| selected_value | * | 仅输出 select 指定的输入内容 |
| selected_label | STRING | 所选输入槽位的标签 |
| selected_index | INT | 所选输入的索引(与 select 相同) |