ComfyUI > Nodes > ControlFlowUtils > 🔀 IF (Condition Selector)

ComfyUI Node: 🔀 IF (Condition Selector)

Class Name

IfConditionSelector

Category
🐺 VykosX-ControlFlowUtils
Author
VykosX (Account age: 2024days)
Extension
ControlFlowUtils
Latest Updated
2024-10-01
Github Stars
0.06K

How to Install ControlFlowUtils

Install this extension via the ComfyUI Manager by searching for ControlFlowUtils
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ControlFlowUtils in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

🔀 IF (Condition Selector) Description

Evaluate conditions between parameters to control execution flow with flexibility, lazy evaluation, inversion, and output customization.

🔀 IF (Condition Selector):

The IfConditionSelector node is designed to evaluate a specified condition between two parameters, A and B, and alter the flow of execution based on whether the condition evaluates to TRUE or FALSE. This node supports a variety of conditions, including logical comparisons, equality checks, and custom expressions, providing flexibility in controlling the execution path. It is particularly useful for creating dynamic and conditional workflows in your AI art generation process. By enabling lazy evaluation, the node ensures that only the necessary inputs are processed, optimizing performance. Additionally, the node can invert the result of the condition if needed, and it can either return boolean results or forward specific inputs based on the evaluation outcome.

🔀 IF (Condition Selector) Input Parameters:

condition

This parameter specifies the condition to evaluate between the inputs A and B. The available options include logical comparisons such as "A is TRUE", "B is TRUE", "A == B", "A != B", "A > B", "A >= B", "A < B", "A <= B", and more. There is also a "CUSTOM" option that allows you to define a custom expression for evaluation. The condition determines the output of the node based on the comparison result.

require_inputs

This BOOLEAN parameter controls whether the node should forward the TRUE_IN and FALSE_IN inputs based on the evaluation result. If enabled (default is True), the node will forward the TRUE_IN input if the condition is TRUE and the FALSE_IN input if the condition is FALSE. If disabled, the node will return raw boolean values (True or False) based on the evaluation result. The labels for this parameter are "Return Inputs" when enabled and "Return Boolean" when disabled.

NOT

This BOOLEAN parameter inverts the result of the condition after it has been evaluated. If enabled, a TRUE result will be inverted to FALSE and vice versa. This can be useful for reversing the logic of the condition without modifying the condition itself.

custom_expression

This STRING parameter allows you to define a custom expression to be evaluated when the condition is set to "CUSTOM". The default value is "2a == 5b+2", and it supports multiline input. Within the custom expression, you can use the variables A and B to refer to the respective inputs, as well as any named global variables from Memory Storage nodes. This parameter is only active when the condition is set to "CUSTOM".

🔀 IF (Condition Selector) Output Parameters:

result

The output of the node is determined by the evaluation of the specified condition. If the require_inputs parameter is enabled, the node will forward the TRUE_IN input if the condition evaluates to TRUE and the FALSE_IN input if the condition evaluates to FALSE. If require_inputs is disabled, the node will return raw boolean values (True or False) based on the result of the condition. The output is crucial for controlling the flow of execution in your AI art generation process, allowing for dynamic and conditional behavior.

🔀 IF (Condition Selector) Usage Tips:

  • Use the "CUSTOM" condition option to create complex and specific conditions tailored to your workflow needs.
  • Enable the NOT parameter to easily invert the logic of your condition without changing the condition itself.
  • Utilize the require_inputs parameter to control whether the node should forward specific inputs or return boolean values, depending on your workflow requirements.
  • Take advantage of lazy evaluation to optimize performance by ensuring only the necessary inputs are processed based on the specified condition.

🔀 IF (Condition Selector) Common Errors and Solutions:

"Unable to block execution, please update your ComfyUI to enable this functionality!"

  • Explanation: This error occurs when the node attempts to block execution due to a failed condition, but the required functionality is not available in your version of ComfyUI.
  • Solution: Update your ComfyUI to the latest version to ensure that the execution blocking functionality is supported.

"ERROR PROCESSING CONDITION: <error_message>. DEFAULTING TO FALSE."

  • Explanation: This error indicates that an exception occurred while processing the specified condition, causing the node to default to a FALSE result.
  • Solution: Check the condition and custom expression for any syntax errors or unsupported operations. Ensure that the inputs A and B are valid and compatible with the specified condition.

🔀 IF (Condition Selector) Related Nodes

Go back to the extension to check out more related nodes.
ControlFlowUtils
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.