monomind Posted February 21, 2021 Share Posted February 21, 2021 Is there any way to get the number of primitives in a group? I've been trying to figure out. Quote Link to comment Share on other sites More sharing options...
anim Posted February 22, 2021 Share Posted February 22, 2021 In VEX: nprimitivesgroup() In Hscript: nprimsgroup() Quote Link to comment Share on other sites More sharing options...
monomind Posted February 22, 2021 Author Share Posted February 22, 2021 oh my bad! Trying to get number of pieces in a group - where each piece is multiple primitives. (voronoi pieces) Quote Link to comment Share on other sites More sharing options...
anim Posted February 22, 2021 Share Posted February 22, 2021 there is no guarantee that the group contains all the primitives of the piece, but to check how many unique different piece attribute values are there in the geo you can use nuniqueval() so delete all geo except for your group and call this function on resulting geo If however you are certain that all the prims of each piece are either in or not in the group you can use Pack SOP to pack pieces based on your piece attribute and transfer the group, then just count prims within that group as per first post Quote Link to comment Share on other sites More sharing options...
ftaswin Posted February 22, 2021 Share Posted February 22, 2021 // in detail wrangle : int prims[] = expandprimgroup(0,"primgroupname"); string pieces[] = {}; foreach(int p;prims) { string nm = prim(0,"name",p); if(find(pieces, nm) < 0) { append(pieces, nm); } } s[]@nm = pieces; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.