lulu01 Posted February 24, 2019 Share Posted February 24, 2019 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? Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted February 24, 2019 Share Posted February 24, 2019 (edited) 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 February 24, 2019 by konstantin magnus Quote Link to comment Share on other sites More sharing options...
anim Posted February 24, 2019 Share Posted February 24, 2019 you can also use group binding to get membership of the current element within a group v@Cd = set(0, i@group_active, 0); 1 Quote Link to comment Share on other sites More sharing options...
lulu01 Posted February 24, 2019 Author Share Posted February 24, 2019 Thank you so much, I understand what I did wrong . You guys where very helpful. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.