vex that selects polygon size

   2139   8   0
User Avatar
Member
36 posts
Joined: Oct. 2018
Offline
I’m using the following vex to attempt to create a Min max controller with selecting specific polygon sizes and outputting a group from this. But it’s not working and I’m not sure if I’m writing this wrong or not. Thoughts?

float minSize = ch("min_size", 0.1);
float maxSize = ch("max_size", 0.2);

if (@area >= minSize && @area <= maxSize)
{
setprimgroup(geoself(), "selected_polygons", @primnum, 1);
}
else
{
removeprimgroup(geoself(), "selected_polygons", @primnum);
}
Edited by luidox - Sept. 23, 2023 15:49:59
User Avatar
Member
153 posts
Joined: June 2020
Offline
luidox
else
{
removeprimgroup(geoself(), "selected_polygons", @primnum);
}

It works fine if you remove those lines. The removeprimgroup function only takes 2 arguments but I'm not sure why you're using that function anyways...

Also wrangles won't show group highlighting unless you type the group name in the Output Selection Group parameter under the bindings tab!
Edited by freshbaked - Sept. 23, 2023 18:21:54
User Avatar
Member
36 posts
Joined: Oct. 2018
Offline
Unfortunately, the sliders don’t work. Whenever I start moving them from position zero the selection disappears under my group promote. Even without removing the else statement. It still does that I’m not really sure what to do.
User Avatar
Member
5128 posts
Joined: Feb. 2012
Offline
Here is one way:

float minarea = ch("min_area");
float maxarea = ch("max_area");

float area = primintrinsic ( 0, "measuredarea", @primnum );
if ( area >= minarea && area <= maxarea )
    i@group_prims = 1;

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
36 posts
Joined: Oct. 2018
Offline
In this case your using a measure node?
User Avatar
Member
5128 posts
Joined: Feb. 2012
Offline
luidox
In this case your using a measure node?

No. I am just checking the area using the primitive intrinsic attribute called "measuredarea".
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
153 posts
Joined: June 2020
Offline
luidox
Unfortunately, the sliders don’t work.

Not sure what else to say other than to just use animatrix_'s more succinct solution.

But to demonstrate that your code works fine here is a screenshot.
Edited by freshbaked - Sept. 24, 2023 12:29:11

Attachments:
selectprimbyarea.png (2.3 MB)

User Avatar
Member
36 posts
Joined: Oct. 2018
Offline
Whats your measure settings?
User Avatar
Member
153 posts
Joined: June 2020
Offline
luidox
Whats your measure settings?
Default. It's already setup to measure the area of each primitive.
  • Quick Links