Jump to content
lulu01

VEX Function: npointsgroup

Recommended Posts

Hi,

Im started out learning vex and exploring different type of function. Im trying out the if statement in combination with the npointsgroup function.
In the example I got a point grid, with a point group. I like to use the if statement to make the grouped points green.
Sound super basic right, but its not working out for me. What I'm doing wrong here?

Screenshot_4.png

Share this post


Link to post
Share on other sites

npointsgroup() returns the number of all points within a specific group. So if there are 5 points in a group, it will always return 5. Its not meant for iterating over points. 

int pts = npointsgroup(0, 'group1');

inpointgroup() however returns whether a certain point @ptnum is in a specific group or not (0 or 1).

v@Cd = vector(0.0);
if( inpointgroup(0, 'group1', @ptnum) != 0){
    v@Cd.r = 1.0;
}

Or more compact:

int in_grp = inpointgroup(0, 'group1', @ptnum);
v@Cd = set( float(in_grp) , 0.0, 0.0);

 

Edited by konstantin magnus

Share this post


Link to post
Share on other sites

you can also use group binding to get membership of the current element within a group

v@Cd = set(0, i@group_active, 0);

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×