Nodes/ComfyUI_Lam/判断选择
ComfyUI Node

判断选择

IfInnerExecute

By yanlang0123·Created 2 years ago·Updated 11 days ago· 77
判断选择
  • ANY
  • IF_TRUE
  • IF_FALSE
  • ?

IfInnerExecute (判断选择, "judgment/selection") is a truthiness switch built for the lam pack's loop system. It takes any value, checks whether it's truthy, and routes the graph down one of two branches. Think of it as the if/else your ComfyUI graph wishes it had.

The reason this matters is the pack's "inner loop" (内循环) workflow style. The pack ships ForStart/ForEnd and DoWhileStart/DoWhileEnd loop nodes, and the example workflows (新版判断循环.json, 新版计次循环.json) are built around exactly this pattern: a loop iterates over prompts or regions, a condition decides whether a pass runs, and the loop continues. Without an if-node, that decision is impossible inside a pure dataflow graph - you'd have to fork the whole workflow. IfInnerExecute is the branch.

How it works

Three inputs: ANY (the condition), IF_TRUE, and IF_FALSE. If ANY is truthy you get IF_TRUE back; if falsy, IF_FALSE. The output's type is whatever the chosen branch's type is - the node is typed * (wildcard), so it adapts.

The clever bit is lazy evaluation. Instead of forcing both branches to compute every run, the node's check_lazy_status inspects ANY first and only asks ComfyUI to evaluate the branch that's actually needed. So if your IF_FALSE branch is a heavy sampler pass that only runs when a condition fails, it genuinely doesn't execute when the condition passes. That's a real optimization in loop workflows where every branch would otherwise burn GPU time per iteration.

The author's own docs give the worked examples:

ANY = 1      → output IF_TRUE
ANY = 0      → output IF_FALSE
ANY = True   → output IF_TRUE
ANY = False  → output IF_FALSE

Inputs and output

  • ANY - any type. Compare with MultiIntFormula's output (p0 > p1), or feed any integer where 0 = false and nonzero = true.
  • IF_TRUE / IF_FALSE - the two candidate payloads, any type, lazy.
  • Output: ? - whatever the selected branch was.

Install

It's in yanlang0123/ComfyUI_Lam - Manager search "ComfyUI_Lam", or:

cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam

then restart. No dependencies beyond the pack's base import, no models, no setup. (The README's install.bat requirement list is for the pack's heavier nodes; pure logic nodes like this one load fine without it.)

Where people get tripped up

Truthiness is Python truthiness, which has a few sharp edges. An empty string, an empty list, 0, and None are all falsy; 0.0 is falsy but a numpy scalar from some nodes may behave differently. If your condition seems backwards, that's usually why. Also remember the lazy behavior only covers IF_TRUE/IF_FALSE - the ANY condition always evaluates, which is what it's for. And one name quirk: it's called "inner" execute because it's built for inner loops; used outside a loop it still works fine as a plain switch.

Categorylam

Inputs (3)

NameTypeDefaultDescription
ANY*
IF_TRUE*
IF_FALSE*

Outputs (1)

NameTypeDescription
?*