Jump to content
Sign in to follow this  
monomind

Number of Prims in a group?

Recommended Posts

Is there any way to get the number of primitives in a group? I've been trying to figure out.

Share this post


Link to post
Share on other sites

oh my bad! Trying to get number of pieces in a group - where each piece is multiple primitives. (voronoi pieces)

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

// 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;

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×