Delete Primitive Groups by an expression/node

   1676   3   1
User Avatar
Member
9 posts
Joined: 12月 2023
オフライン
Hey all! I am trying to create a method to delete primitive groups based on the @P.y value. I have it working to delete the primitive faces, but not the group/(pattern?). Any suggestions? the end goal is to create an hda out of the setup.

I attempted to use a delete expression as well as try to use vex, but I do not know how to select the primitive groups (like @name=tire, @shop_materialpath=licensePlate, etc.) to structure it into an expression. In the second image, you can see the prim group options I would like to delete.

Attachments:
Screenshot 2024-06-07 003632.png (898.5 KB)
Screenshot 2024-06-07 004258.png (1.0 MB)

User Avatar
Member
542 posts
Joined: 11月 2016
オフライン
You could assign P.y to a float attribute and use Attribute Promote with your name or material attribute as a piece attribute to average (or min or max) it over the primitive group. Then just delete with a threshold using this new promoted attribute.
User Avatar
Member
5100 posts
Joined: 2月 2012
オフライン
Hi,

Here is one way to do it using VEX:

float height = ch("height");

string primgroups [ ] = detailintrinsic ( 0, "primitivegroups" );
foreach ( string group; primgroups )
{
    vector center = getbbox_center ( 0, group );
    if ( center.y < height )
    {
        int prims [ ] = expandprimgroup ( 0, group );
        foreach ( int pr; prims )
            removeprim ( 0, pr, 1 );
    }
}


If you know each prim only belongs to a single group, you can optimize it further.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
User Avatar
Member
9 posts
Joined: 12月 2023
オフライン
Thanks for the feedback! I actually resolved this a while ago and completely forgot to follow up with my initial post. I realize some people out there may try to do something similar, so I wanted to explain my solution, as I believe it is a little simpler.

First of all, I essentially applied the logic of @animatrix_, however instead of using VEX, I used the for each connected piece SOP, however I would suggest using For Each Named Piece if the primitives are named and organized already.

I used a point wrangle and created a variable for the getbbox_center() vector position to get the center position of each connected piece,and created an if statement stating if the Y value is greater than a certain value, use the removepoint() function to delete all the points and prims (using the @ptnum attribute).

This is of course a basic setup to get this done, without creating channels and other complementary functionality. Hope this helps someone that was trying something similar. Let me know if anyone needs further explanation or has any questions.

Below is a demo just using craig,but works the same way.

Attachments:
Screenshot 2025-06-28 190042.png (803.0 KB)

  • Quick Links