A While loop runs its body until a condition tells it to stop. The number of iterations isn't fixed in advance. Use a While loop for iterative or convergence algorithms. Unlike a For-Each loop, a While loop has no fixed list of items to process. For a full explanation of how While loops work, see For-Each and While loops.
Click Add node
on the toolbar or press Space.
The Add node dialog opens.
Expand Blank subgraphs and select While subgraph.
The While node is placed on the canvas.
Connect a number to the Max Iterations input port on the While node.
Max Iterations is a safety cap. If the Break condition never becomes true, the loop stops after this many iterations. Always wire this port to prevent runaway loops.
Double-click the While node, or right-click it and choose Enter subgraph, to open the loop body.
Inside the loop body, use the ports on the Subgraph Input node to access loop state:
0Wire your loop logic, then connect to the Subgraph Output node:
true. Wire a condition here.To carry a value from one iteration to the next, use a GetLastItem node on LoopResults to read the previous result and pass the new result to Loop Result.
On the first iteration (Index equals 0), LoopResults is empty. Use an If node to check whether Index equals 0. When it does, provide a seed value. Otherwise, read from LoopResults.
GetListSize node on the LoopResults output.