Addding a name in a for loop for each piece

   2930   3   1
User Avatar
Member
5 posts
Joined: Dec. 2017
Offline
Hello,

I'm trying to do something that i thought it should be pretty easy thing to do but im somehow stuck on it.
I want in a for loop where i modify each primitive to add an unique name to each primitive iteration.

In my actual use case i will extrude edges and create planks, then fracture it based on each name.

This is something close to my current setup, however it does not work

Edited by IANistor - Jan. 16, 2024 07:21:50

Attachments:
test_for_loop.hip (129.1 KB)

User Avatar
Member
8 posts
Joined: Jan. 2019
Offline
Hi, you could do the naming inside the loop. But the easiest way is to just use the connectivity-node a bit differently (as this node can also create string names for us based on connectivity directly).
Just set the 'attribute type' to string, and optionally give it a prefix.

Attachments:
connectivityNames.png (503.4 KB)

User Avatar
Member
545 posts
Joined: Nov. 2016
Offline
As matsvanreenen says, and for your information, your setup would have worked if your AttributeCreate node was between the ForEachBegin and ForEachEnd nodes, otherwise it won't be part of the loop.
User Avatar
Member
47 posts
Joined: Feb. 2017
Offline
If using in loop is nessesary, then put attribwrangle or name node before loop ends. "Add Spare Input" (google it, cool staff) and add foreach_begin1_metadata1 into the field. Then
s@name = "Cool_Name_" + itoa(detail(-1,"iteration",0)); //attribwrangle node
or Cool_Name_`detail(-1,"iteration",0)` (name node). If "Add Spare Input" not an option, add direct reference, replace detail(-1,"iteration",0) with detail("../foreach_begin1_metadata1/","iteration",0) (added just for other peoples)
Edited by tachbek - Jan. 16, 2024 13:00:44
  • Quick Links