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?
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.
Thanks guys! I just thought hashing the name attribute will give me a consistent id based on the group name, and that's actually enough of what i need, coz I don't need to go back from the indices to the groups. I need it to help cluster some geometry.