Create a For-Each loop

A For-Each loop iterates over a list of items and processes each item one at a time. Use it when you need to apply the same set of operations to every item in a list. For example, create a manufacturing operation for each pocket in a design, or apply a parameter change to each component in an assembly. For a full explanation of how For-Each loops work, see For-Each and While loops.

There are two ways to create a For-Each loop: start from a blank For-Each subgraph, or convert an existing standard subgraph.

Start with a blank For-Each subgraph

  1. Click Add node add node icon on the toolbar or press Space.

    The Add node dialog opens.

  2. Expand Blank subgraphs and select For-Each subgraph.

    The loop node is placed on the canvas with Items (input) and LoopResults (output) ports already defined. Inside, the Subgraph Input and Subgraph Output boundary nodes are pre-configured with their For-Each ports.

  3. Connect the list you want to iterate to the Items input port.

  4. Double-click the For-Each node, or right-click it and choose Enter subgraph, to open the loop body.

  5. Inside the loop body, use the ports on the Subgraph Input node to access iteration data:

    • Item: The current list item for this iteration
    • Index: The zero-based position of the current item in the list
    • LoopResults: The accumulated list of results from all previous iterations
  6. Wire your logic nodes, then connect the final output to the Loop Result port on the Subgraph Output node.

    Each iteration appends its result to LoopResults. After all iterations complete, the LoopResults output port on the For-Each node in the parent graph provides the full list.

  7. (Optional) Connect the Break port on the Subgraph Output node to a Boolean output. When Break evaluates to true, the loop stops before processing the remaining items.

Convert an existing subgraph to a For-Each loop

  1. Create the subgraph you want to convert. See Create a subgraph.

  2. Right-click the subgraph node and choose Convert to For-Each.

    The subgraph becomes a For-Each node. The Items and LoopResults ports are added to the parent-facing side. Inside, the Subgraph Input and Subgraph Output boundary nodes gain their For-Each ports.

  3. Review the inner boundary ports after conversion. The editor doesn't rewire any existing inner connections. Reconnect them to the new For-Each ports as needed.

  4. Connect the list to the Items input port and continue wiring as described in steps 4–7 above.

Note: For nested For-Each loops, LoopResults on the outer loop is a list of lists. Each inner loop produces a list; the outer loop collects those into a single outer list.