Nodes/ComfyUI-JDCN/LogicUtil_AAndBGate
ComfyUI Node

LogicUtil_AAndBGate

True only when both inputs are true

By daxcay·Created 2 years ago·Updated about a year ago· 159
LogicUtil_AAndBGate
  • input1
  • input2
  • BOOL

Logic gates are how a graph makes decisions: run the upscaler only if the batch has more than one image and the checkbox is on. LogicUtil_AAndBGate (that's the display name; the class is LogicUtil_LogicGateAnd) takes input1 and input2, and outputs a BOOL that's True only when both inputs are truthy. One input false - even one - and the gate outputs False. It's the "and" from your high-school logic class, dropped into the graph.

How it works

Under the hood it's Python's and, evaluated as a boolean: True if input1 and input2 else False. Both inputs are wildcard *, so they accept anything - numbers, strings, other booleans - and truthiness follows Python's rules: 0, empty strings, empty lists are False; basically everything else is True (and if you want to know exactly what a non-boolean becomes, the pack's LogicUtil_Convert to Bool documents that in painful detail). The output is always a real BOOL, which is the type every switch and conditional consumer actually wants.

Where it fits

  • Gating a conditional branch on two independent conditions: a mode toggle and a non-empty input list.
  • Combining the result of two comparisons (bigger-than checks, string matches) into one decision.
  • Building up a multi-condition check by chaining gates - each one combines the running result with the next condition.

It's one of the gate nodes in the pack's LogicUtil set (the LogicUtil_ prefix marks it as a port of aria1th's ComfyUI-LogicUtils), alongside an OR gate, invert, and compare nodes - the whole boolean toolbox in one category so you don't need a separate logic pack for a couple of gates.

Install

Ships in ComfyUI-JDCN. ComfyUI Manager → Install Custom Nodes → search "JDCN", or:

cd ComfyUI/custom_nodes
git clone https://github.com/daxcay/ComfyUI-JDCN.git
pip install -r requirements.txt

Only pack dependency is piexif (plus psutil, already in ComfyUI). No models to download.

Gotchas

  • "Truthy" is not "equal to True." A string "false" is truthy (non-empty), so it'll pass the gate. If you need a strict boolean comparison, convert first.
  • Default inputs are 0 - both inputs default to 0.0, which is falsy, so an unwired gate outputs False. If a conditional never fires, check for a dangling wire feeding a gate input.
  • Short-circuit doesn't apply in the UI - both inputs get evaluated by the graph anyway; this isn't a performance optimization, just a decision node.

Two inputs, one boolean, no config. The gate you'll actually use when your workflow starts making choices instead of just rendering.

CategoryLogicUtil

Inputs (2)

NameTypeDefaultDescription
input1*0
input2*0

Outputs (1)

NameTypeDescription
BOOLBOOL