Jump to content

VEX Function: npointsgroup


lulu01

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

Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...