PD:if
If — a real boolean AND gate for workflows that need a brain
- cond_1
- cond_2
- output
- count
Core ComfyUI has switch nodes up the wazoo, but a plain boolean "is everything here true?" gate is oddly missing. PD:if is that missing gate. It takes a boolean toggle plus two any-typed inputs and returns True only if all three are truthy - the boolean AND that lets you gate a branch on multiple conditions at once.
Where you reach for this: you've got a workflow that should only fire when several things line up - a mask exists, a toggle is on, a saved-count came back nonzero - and you want one signal to drive a switch or an execution blocker instead of hand-wiring a pile of Any Switch nodes. Because cond_1 and cond_2 are * (any) type, you can plug in anything: an image (truthy unless it's an empty tensor), a string, an INT, even another boolean. The node runs Python's bool() on each and ANDs them together.
How it works
Straight from the source, the logic is one line: result = bool(cond_1) and bool(cond_2) and bool(if). The if input is just another condition, with a True default so it's a pass-through toggle you can flip to disable the whole gate without unplugging wires. There's no short-circuit cleverness and no state - it's a pure function of its inputs.
The two outputs:
- output (
BOOLEAN) - the AND result, ready to drive a switch. - count (
INT) - 1 if the node ran successfully, 0 if it hit an exception. This is a success flag, not a run counter.
That count naming trips people up. Read the README: "执行成功输出 1,异常输出 0" - success outputs 1, exception outputs 0. It is not "how many times this has run." If you want a real run counter, look at loop/accumulator packs instead.
A workflow shape that uses it
Say you have a detailer branch that should only run when (a) a OnlyFirst toggle is on, and (b) the image batch actually has more than one frame. Wire the toggle into if, an INT from a frame-count node into cond_1, and anything into cond_2. The output goes to a Switch node that passes either the original or the detailed version downstream. One wire does the gating, the graph stays readable.
The counter-flag output is handy for a different job: wire it into an Execution Blocker-style node or a report string so a failed gate visibly breaks the run instead of silently passing an empty result through.
Install
ComfyUI Manager: search PDuse (repo 7BEII/Comfyui_PDuse), install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse
cd Comfyui_PDuse
pip install -r requirements.txt
Restart ComfyUI and look for PD:if under the PDuse/Logic category.
Gotchas
The if input isn't special - it's just condition number three with a default on. And remember the any-type trick cuts both ways: an empty string or a zero-INT is falsy, so "is this connected at all" is not what the node checks; it checks "is this truthy." For a pure connectivity test you'd want something that actually errors when the wire is missing. Other than that, it's a tiny node that does one thing correctly - wire it, trust it, move on.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| if | BOOLEAN | true | — |
| cond_1 | * | — | |
| cond_2 | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| output | BOOLEAN | — |
| count | INT | — |