Loops allow you to automate entire sections of your workflow by repeating the nodes connected to the Loop a specific number of times or until a specific condition no longer applies.
To use this node, you must link the Loop Output of the [Loop Open] node to the Loop Input of a [Loop Close] node. If you wish to iterate a predefined amount of times (such as when using a For Loop) then set your Start, Step and End parameters accordingly. If you would like the Loop to behave as a While Loop instead, then you may set a Condition which must evaluate to True in order for the loop to execute, and it will continue executing indefinitely until the condition no longer evaluates to True. In order to use the Loop as a pure While Loop, you should set Step to 0. You can also have a combined Loop of both For and While types by having both a Condition and a Step set such that the Loop will continue to execute until the Codition is no longer true OR it fully iterates from Start to End, whichever happens first.
You can set the Data and Aux Data Inputs to any Data you wish to iterate on for each execution of the Loop. The data will be preserved so long as you link the Outputs from [Loop Open] node to the relevant Inputs of the [Loop Close] nodes. The LOOP Input is a dictionary containing information about the Loop. It may be intercepted and accessed via [Data Monitor] nodes to extract information about the current Loop, such as the Index, Start, Step, End, Finished status, Condition, and other useful information.
Once the Loop is done executing, the FINISHED? Output will return True. If Condition does not evaluate to True for the [Loop Close] node, the loop will terminate and no further iterations will be processed. The final values of any data that has been processed by the Loop can be accessed via the Data and Aux Data Outputs of this node, provided they have been passed to the relevant Inputs.
This node uses the new Execution Inversion mechanics and requires an updated version of ComfyUI. It works by dynamically cloning all the nodes that are connected as children of the [Loop Open] and [Loop Close] nodes, while forwarding the data to the copies on each iteration. This is still a bit of proof of concept, so issues may occur. Please report any bugs on the Issues page of this node pack's Github repo!
HOVER OVER THE INPUTS AND OUTPUTS FOR MORE INFO.
By VykosX·Created 2 years ago·Updated 2 years ago· 147
⏹️ Loop Close
LOOP
data
aux
aux2
aux3
aux4
aux5
FINISHED?
data
aux
aux2
aux3
aux4
aux5
◄conditionTrue►
Category🐺 VykosX-ControlFlowUtils
Inputs (8)
Name
Type
Default
Description
LOOP
*
Connect to the LOOP output of a [Loop Open] node to establish a Loop
condition
STRING
True
The loop will be executed only if the specified condition evaluates to True
dataopt
*
Any data you wish to iterate on in the loop
auxopt
*
Any auxilliary data you wish to iterate on in the loop
aux2opt
*
Any auxilliary data you wish to iterate on in the loop
aux3opt
*
Any auxilliary data you wish to iterate on in the loop
aux4opt
*
Any auxilliary data you wish to iterate on in the loop
aux5opt
*
Any auxilliary data you wish to iterate on in the loop
Outputs (7)
Name
Type
Description
FINISHED?
BOOLEAN
This output will return True when the Loop is done executing
data
*
Final values for any Data that has been processed by the Loop
aux
*
Final values for any Data that has been processed by the Loop
aux2
*
Final values for any Data that has been processed by the Loop
aux3
*
Final values for any Data that has been processed by the Loop
aux4
*
Final values for any Data that has been processed by the Loop
aux5
*
Final values for any Data that has been processed by the Loop