Hi,
Quick one here
I have some geometry with many primitive groups. I'd like to create an attribulte “groupid” which will store an index of the group. Say I have 10 groups, so the attribute would be 0 on group1, 1 on group2 etc…
Which node should I use? Attribute Wrangle? But how?
Cheers,
B.
Turning many groups into a single integer attribute
2927 6 1- bbbaaarrr
- Member
- 14 posts
- Joined: April 2017
- Offline
- BabaJ
- Member
- 2038 posts
- Joined: Sept. 2015
- Offline
- bbbaaarrr
- Member
- 14 posts
- Joined: April 2017
- Offline
- friedasparagus
- Member
- 402 posts
- Joined: June 2014
- Offline
Hi B,
you can use the ‘Name SOP’ to create a primitive attribute from groups. You can do any iterations you wanted using that attribute in for-loops etc… so you may well be able to stop there.
Or if you really want an integer attribute you can look up the index of that new ‘name’ attribute in the “primitivegroups” detail intrinsic attribute (see the attached file). Bear in mind that the ordering of groups is not very easy to keep track of or control if you need to change any groupings upstream, so your integer attribute may not behave as you might expect, depending what you want to do with it.
Hope that helps,
Henry
you can use the ‘Name SOP’ to create a primitive attribute from groups. You can do any iterations you wanted using that attribute in for-loops etc… so you may well be able to stop there.
Or if you really want an integer attribute you can look up the index of that new ‘name’ attribute in the “primitivegroups” detail intrinsic attribute (see the attached file). Bear in mind that the ordering of groups is not very easy to keep track of or control if you need to change any groupings upstream, so your integer attribute may not behave as you might expect, depending what you want to do with it.
Hope that helps,
Henry
Henry Dean
- BabaJ
- Member
- 2038 posts
- Joined: Sept. 2015
- Offline
Ok..so I changed it to accomodate large number of groups.
Mind you, this only works if the prims only ever belong to one group,
otherwise they get the last group checked as the indice of the group the prim belongs too.
Of course it's only a minor change to the code if you intend to have a prim/s belong to more than one group.
Mind you, this only works if the prims only ever belong to one group,
otherwise they get the last group checked as the indice of the group the prim belongs too.
Of course it's only a minor change to the code if you intend to have a prim/s belong to more than one group.
- bbbaaarrr
- Member
- 14 posts
- Joined: April 2017
- Offline
- N_Mateja
- Member
- 13 posts
- Joined: Dec. 2018
- Offline
BabaJ
Ok..so I changed it to accomodate large number of groups.
Mind you, this only works if the prims only ever belong to one group,
otherwise they get the last group checked as the indice of the group the prim belongs too.
Of course it's only a minor change to the code if you intend to have a prim/s belong to more than one group.
This just helped me out! Thanks for posting the file. Really appreciated
-
- Quick Links