Nodes/ControlFlowUtils/πŸ”€ IF (Condition Selector)
ComfyUI Node

πŸ”€ IF (Condition Selector)

Allows you to test for a condition and change the flow of execution on your prompt based on whether the condition evaluates to TRUE or FALSE. This node supports Lazy evaluation. Only the Inputs that are required based on the specified condition will be executed. A and B are the parameters that will be tested against each other and Condition specifies what kind of comparison will be made between them. If NOT is enabled then the condition will be reversed after evaluation. If Require_Inputs is enabled, then you must specify the TRUE_IN and FALSE_IN inputs as their values will be forwarded to the Output based on the results of the evaluation i.e. TRUE_IN will be forwarded if the condition evaluates to TRUE and FALSE_IN will be forwarded if the condition evaluates to FALSE. If Require_Inputs is disabled then TRUE_IN and FALSE_IN can be omitted and the raw boolean values True and False will be returned based on the result of the comparison. If Condition is set to CUSTOM, you may further specify a custom expression which will be evaluated. Within this expression you may use the variables A and B to refer to those respective inputs as well as any named global variables from [Memory Storage] nodes. Most valid Python expressions, types and built-in functions are supported in the custom expression. For a full list of supported operations please consult the file 'Helper.py' included in this node pack. HOVER OVER THE INPUTS AND OUTPUTS FOR MORE INFO. When the condition is set to 'CUSTOM', the parameters Input A and Input B used in the custom_expression must not be None.

By VykosXΒ·Created 2 years agoΒ·Updated 2 years agoΒ· 147
πŸ”€ IF (Condition Selector)
  • A
  • B
  • TRUE_IN
  • FALSE_IN
  • *
β—„conditionβ–Ύβ–Ί
β—„require_inputstrueβ–Ί
β—„NOTβ€”β–Ί
β—„custom_expression2*a == 5*b+2β–Ί
Category🐺 VykosX-ControlFlowUtils

Inputs (8)

NameTypeDefaultDescription
conditionCOMBOCondition to evaluate. The output will be set to the result.
require_inputsBOOLEANtrueEnable to forward TRUE_IN/FALSE_IN Inputs of this node, disable to return Boolean results
NOTBOOLEANInvert the result of the condition post-evaluation
custom_expressionSTRING2*a == 5*b+2Custom expression used with the CUSTOM Condition
Aopt*First Input to Evaluate
Bopt*Second Input to Evaluate
TRUE_INopt*Input to forward if the expression evaluates to True
FALSE_INopt*Input to forward if the expression evaluates to False

Outputs (1)

NameTypeDescription
**Result of the comparison. Either a forwarded input or a boolean value depending on whether Required_Input is set