Skip to content

Loop Close

Closes and advances a Loop created by a Loop Open node. It evaluates a user-defined condition and either schedules the next iteration (carrying forward data/aux values) or stops the loop and returns final values. It also outputs a boolean flag indicating when the loop has finished.
Preview

Usage

Use this node in tandem with Loop Open. Connect Loop Open's LOOP output to this node's LOOP input, route any iterative state (data/aux/aux2/aux3/aux4) through both nodes, and set a condition that controls whether to continue iterating. Downstream nodes can wait for FINISHED? to become True to proceed with post-loop processing.

Inputs

FieldRequiredTypeDescriptionExample
LOOPTrue*Loop state dictionary produced by Loop Open. Establishes the loop context and provides index, step, progress, and other status values.{'id': 12345, 'index': 0, 'step': 1, 'finished': False}
conditionTrueSTRINGA boolean expression evaluated against the loop variables and any provided inputs. If it evaluates to False, the loop stops and outputs final values.index < 10 and condition_open
dataFalse*Primary data being iterated or accumulated across iterations. Connect the matching output from Loop Open to preserve and update state.{'images': ['img1.png', 'img2.png']}
auxFalse*Auxiliary data to carry across iterations.{'count': 5}
aux2False*Additional auxiliary slot for iterative state.['a', 'b']
aux3False*Additional auxiliary slot for iterative state.0.75
aux4False*Additional auxiliary slot for iterative state.{'threshold': 0.9}

Outputs

FieldTypeDescriptionExample
FINISHED?BOOLEANTrue when the loop has stopped (either because the condition evaluated to False or the loop reports finished).True
data*Final value of the primary iterative data after the loop completes, or the updated value passed to the next iteration.{'images': ['img1.png', 'img2.png', 'img3.png']}
aux*Final value of the auxiliary data after loop completion, or the updated value passed to the next iteration.{'count': 10}
aux2*Final value of the second auxiliary slot.['a', 'b', 'c']
aux3*Final value of the third auxiliary slot.0.95
aux4*Final value of the fourth auxiliary slot.{'threshold': 0.9}

Important Notes

  • Pairing required: Must be used with Loop Open. Connect Loop Open's LOOP output to this node's LOOP input.
  • Condition evaluation: The condition is a string expression evaluated against loop variables (e.g., index, step, finished) and your connected inputs. An empty condition defaults to True.
  • Finish criteria: The loop stops when LOOP.finished is True or when the close-side condition evaluates to False.
  • State persistence: To persist and update iterative state, route data and aux outputs from Loop Open into the matching inputs of Loop Close on each cycle.
  • Multiple aux slots: Up to four auxiliary slots (aux, aux2, aux3, aux4) are available for additional iterative state.
  • Output behavior: When the loop ends, FINISHED? becomes True and outputs return the final values; during ongoing iterations, this node schedules the next iteration instead of immediately returning final values.

Troubleshooting

  • No iteration occurs: Ensure Loop Open's LOOP output is connected to Loop Close's LOOP input and that the open-side condition allows entry.
  • Loop ends immediately: Your close-side condition may be False on the first check or LOOP.finished may already be True. Inspect index, step, end, and your condition expression.
  • Infinite or unexpected looping: Revisit both open-side and close-side conditions and how index changes. If using index overrides upstream, verify they increment or terminate properly.
  • State not updating: Make sure you're feeding updated data/aux values back into Loop Open via Loop Close's expansion path and that the names match (data ↔ data, aux ↔ aux, etc.).
  • Condition errors: If the condition references variables, ensure they exist in the loop context (e.g., index) or are passed via inputs. Invalid expressions will cause the condition to evaluate unsuccessfully.