Leave only the first prim in a prim group

   806   3   0
User Avatar
Member
74 posts
Joined: Jan. 2015
Offline
In a prim group, how do I remove all prims except the first one? I tried a Prim Wrangle, with the desired group in the "Group" field, like so:
if (@primnum>0) removeprim(0,@primnum,1);
But it removes all prims in a group (seems like @primnum starts at 0 for the entire geometry, not for the desired group). I can Split-SOP by group, then remove all prims but the first one, then merge back all geometry, but I'd like to do this without splitting. In a Prim Wrangle, I can also iterate through all prims, check group membership, save the first prim and remove all others, but maybe there's a way without iterating through all prims.
Edited by element33 - Nov. 22, 2022 19:20:01
User Avatar
Member
8594 posts
Joined: July 2007
Offline
Not by Houdini right now, but you should be able to do something like this
int prims[] = expandprimgroup(0, "mygroup");
if (@primnum != prims[0]){
    removeprim(0, @primnum, 1);
}
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
74 posts
Joined: Jan. 2015
Offline
tamte
Not by Houdini right now, but you should be able to do something like this
Cook, thanks.
User Avatar
Member
4528 posts
Joined: Feb. 2012
Offline
If you want the fastest performance though, I would recommend doing this using the Blast SOP with this expression:

`arg(primlist(0, "myprimgroup"), 0)`

If you want to do this for an arbitrary number of groups, then I would gather all the first elements into an array using a Detail Wrangle, turn this array into a space separated string and then use that with Blast SOP.
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 | pragmaticvfx.gumroad.com
  • Quick Links