vex that selects polygon size

   2136   8   0
User Avatar
Member
36 posts
Joined: 10月 2018
オフライン
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 - 2023年9月23日 15:49:59
User Avatar
Member
153 posts
Joined: 6月 2020
オフライン
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 - 2023年9月23日 18:21:54
User Avatar
Member
36 posts
Joined: 10月 2018
オフライン
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
5125 posts
Joined: 2月 2012
オフライン
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: 10月 2018
オフライン
In this case your using a measure node?
User Avatar
Member
5125 posts
Joined: 2月 2012
オフライン
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: 6月 2020
オフライン
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 - 2023年9月24日 12:29:11

Attachments:
selectprimbyarea.png (2.3 MB)

User Avatar
Member
36 posts
Joined: 10月 2018
オフライン
Whats your measure settings?
User Avatar
Member
153 posts
Joined: 6月 2020
オフライン
luidox
Whats your measure settings?
Default. It's already setup to measure the area of each primitive.
  • Quick Links