select the largest in each group

   3891   4   1
User Avatar
Member
125 posts
Joined: April 2014
Offline
I have several groups of primitives and I want to select the one with the largest value (@foo) in each group.

I figure I can use a for next to iterate over each group but how might I go about isolating the one with the largest value in each group?

thanks in advance
User Avatar
Member
125 posts
Joined: April 2014
Offline
my apologies, that could be more clear.

I have several groups. From each group I want to select the primitive with the largest value in @foo.
User Avatar
Member
65 posts
Joined: Feb. 2013
Online
Maybe you can use a foreach, based on group (I think you should create an attribute from the groups for that), promote the attribute @foo to detail using “max” option when promoted and than check if the primitive attribute is == to the detail attribute … and … can you share your file?
User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
Additionally you can use the sort node by attribute and delete all prims but the first.
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
4516 posts
Joined: Feb. 2012
Offline
To check all point groups for point attribute “attrib”, you can write something like this inside AttribWrangle SOP in Detail Mode to gather them in a point group called “maxvals”:

string groups [ ] = detailintrinsic ( 0, "pointgroups" );
float maxvals [ ];
int pts [ ];
resize ( maxvals, len ( groups ) );
resize ( pts, len ( groups ) );

foreach ( int index; string g; groups )
{
    maxvals [ index ] = -1e10;
    int elements [ ] = expandpointgroup ( 0, g );
    foreach ( int elem; elements )
    {
        float val = point ( 0, "attrib", elem );
        if ( val > maxvals [ index ] )
        {
            maxvals [ index ] = val;
            pts [ index ] = elem;
        }
    }
}

foreach ( int pt; pts )
    setpointgroup ( 0, "maxvals" , pt, 1 );
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
  • Quick Links