Hi there!
I have a seletion of debris items in various sizes. I would like to give them a sorted name attribute based on their surface area.
Getting the area per piece in a loop is easy enough but how can I use this float value to name the pieces in rising order from small to large? So piece01 would always be the smallest and piece0X will be the largest.
Also the float values for area are huge cumbersome numbers, idealy I would want to remap those into a range matching the number of the pieces.
Thanks!
Using the area of a piece to create name attribute
2246 6 2-
- Tora_2097
- Member
- 32 posts
- Joined: May 2019
- Offline
-
- animatrix_
- Member
- 5100 posts
- Joined: Feb. 2012
- Offline
Hi,
Here is one way:

Sort by area
Attribute Promote (name) -> from Primitive to Detail -> Array of All
unique_names_array (Detail Wrangle):
assign_unique_indices_per_piece (Primitive Wrangle):
Here is one way:

Sort by area
Attribute Promote (name) -> from Primitive to Detail -> Array of All
unique_names_array (Detail Wrangle):
string allnames [ ] = detail ( 0, "allnames" ); string names [ ] = { }; foreach ( string name; allnames ) if ( find ( names, name ) < 0 ) append ( names, name ); s[]@allnames = names;
assign_unique_indices_per_piece (Primitive Wrangle):
string allnames [ ] = detail ( 0, "allnames" ); i@index = find ( allnames, @name ); s@newname = sprintf ( "piece%s", i@index );
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
-
- Tora_2097
- Member
- 32 posts
- Joined: May 2019
- Offline
-
- animatrix_
- Member
- 5100 posts
- Joined: Feb. 2012
- Offline
Oh I see, I forgot to mention the attribute has to be renamed to allnames in Attrib Promote:
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
-
- Tora_2097
- Member
- 32 posts
- Joined: May 2019
- Offline
-
- Tora_2097
- Member
- 32 posts
- Joined: May 2019
- Offline
-
- Fenolis
- Member
- 152 posts
- Joined: Aug. 2012
- Offline
-
- Quick Links


