Basic For Loop question

   961   1   0
User Avatar
Member
47 posts
Joined: Aug. 2015
Offline
What is the primary difference between ‘For Each Connected Piece’ and ‘For Each Named Primitive’. Are there advantages for one over the other in different circumstances? Thanks a bunch for any feedback.
User Avatar
Member
21 posts
Joined: Sept. 2018
Offline
They both function the same way. They look at which primitives or points (depending on the ‘Piece Element’ setting on the ‘foreach_end’ node) and takes the ones sharing the ‘class’ or ‘name’ attribute into a single iteration of the loop. These are presets of the loop nodes. You could change the attributes it looks for to ‘OOGABOOGA’ and it wouldn't matter. There are two versions because both setups are often used and having them in there saves time having to set up a single default ‘loop’ preset.

'For Each Connected Piece' gives the primitives (or points) of each connected piece the same attribute. So any primitives that are connected by points get one shared ‘class’ attribute. Doesn't matter if it's a box or a curve, so long as the points are connected, they are considered one piece and will enter the loop at the same time. This option in the TAB menu prepends a ‘connectivity’ SOP that determines which primitives/points are connected. The ‘foreach_end’ looks for ‘class’ in this preset.

'For Each Named Primitive' looks for ‘name’ instead of ‘class’ by default. Unlike ‘For Each Connected Piece’ it assumes you already have a ‘name’ attribute on your geometry so you do not get a ‘connectivity sop. This way, before you enter the loop you could give two primitives on a box one name, and the other four primitives on the same box another name, and now unlike with the above example your box would have the first two primitives sent into a loop by themselves, followed by another loop containing the other four. Alternatively, you could give each primitive on two different boxes the same ’name' attribute, and both boxes now enter the loop at the same time.

Again they are simply presets. I could make a ‘connectivity’ myself and add it in before a ‘For Each Named Primitive’, change the attribute in the ‘connectivity’ to ‘name’, set it to ‘Primitives’ and it would function identically to ‘For Each Connected Piece’.
Edited by vandoornjerry - Oct. 26, 2019 15:29:32
  • Quick Links