Skip to content

For Each Piece

For Each Piece and End For Each are a loop. The nodes wired between them, the loop’s body, run once for every piece of the mesh going into For Each Piece, and End For Each merges what they made. Use it when each piece needs the same work on its own: Import a model, then For Each Piece (Imported part) into Polyreduce into End For Each, and every part gets its own reduction budget instead of the big parts using it all up.

  • Adding one. Pick For Each Piece from the add menu: both nodes appear, already wired together. Put the nodes you want to repeat between them. Dropped on a wire, the pair goes into the wire like a single node.
  • From picked parts. Click parts of an imported model in the viewport, then hold Ctrl and pick For Each Piece from the radial menu: the loop goes in after the pick, set to loop just those parts (Pieces from Imported part, Apply to the pick). For Each Piece is selected, so hold Ctrl again and pick Polyreduce to reduce each picked part on its own budget. Parts picked from more than one model (more than one Merge input) can’t share one loop; the entry is dimmed and says so.
  • Wrapping a chain. Select the nodes you want to repeat and pick Wrap in For Each Piece from the right-click menu (or press Ctrl+Shift+L): For Each Piece goes in before them and End For Each after them. The chain needs one way in and one way out; if it has more, the menu entry says why it can’t wrap it.
  • Seeing the loop. The two nodes share a colour, and every node between them gets a thin outline in it, so you can see at a glance what the loop repeats. The outline follows the wires as you change them.
  • The pieces. Pieces from decides what one piece is: faces joined to each other (Connected), each part of an imported model (Imported part), or faces sharing a value of a face attribute such as name (By attribute; faces without a value make one more piece). Pieces are numbered like Separate Pieces numbers them, largest first.
  • Working on one piece. For Each Piece’s own output is the Preview piece. Display any node inside the loop and you see what it does to that one piece, so tuning the body stays fast. Step through the pieces with the arrows beside Preview piece. Display End For Each to run every piece.
  • Only some pieces. Apply to limits the loop to named selections, for example two imported parts: only their pieces run through the loop, and every other face passes through unchanged. Everywhere loops every piece.
  • Geometry from outside. A node in the body can also read geometry from outside the loop, such as a cutter for a Boolean. It is made once and every piece uses it.
  • Staying inside. A node in the body must not feed a node outside the loop, except End For Each. If it does, it gets a red badge and the loop stops: wire the outside node from End For Each instead.
  • When a piece fails. If the body fails on one piece, the whole loop fails and says which piece and which node, for example piece 7 (“roof_beam”) failed at Polyreduce. The Show piece 7 button under the message previews that piece and displays the node that failed.
  • Loops inside loops and subnets. A loop can sit inside another loop’s body, for example once per imported part and, inside it, once per connected island of that part. Loops also work inside subnets, and a body can hold subnets. A loop’s two nodes must be on the same graph level, never one outside a subnet and the other inside it.
  • The result. Every face End For Each puts out is labelled with its piece: a piece attribute and a piece_0, piece_1, … selection. For imported parts it also keeps the part’s name and selection, and By attribute keeps the piece’s attribute value, even when a node in the body (Remesh, say) dropped them, so picking parts in the viewport and a second loop still work afterwards.
Mesh

The mesh whose pieces to loop over.

Mesh

One piece, the Preview piece, so the loop’s body can be seen and tuned on it. End For Each runs every piece.

Parameter What it does Default
Apply to Which faces the loop runs on. Everywhere loops every piece; pick named selections (such as imported parts) to loop only those pieces, the rest passing through unchanged. Everywhere
Pieces from What makes one piece. Connected: faces joined to each other. Imported part: each part of an imported model. By attribute: faces sharing a value of a face attribute. Options: Connected, Imported part, By attribute Connected
Attribute The face attribute whose values make the pieces: one piece per value. Picked from the input mesh. Shown when Pieces from is By attribute. None
Preview piece The piece the loop’s body shows while you work on it: 0 is the largest. End For Each still runs every piece. 0
Loop Links this node to the other half of its loop. Blank
Mesh

The last node of the loop’s body (or For Each Piece itself for an empty loop).

Mesh

Every piece’s result merged, each face labelled with its piece (`piece` attribute and `piece_<n>` selection) and, for imported parts, its part again.

Parameter What it does Default
Loop Links this node to the other half of its loop. Blank