waltt Posted March 23, 2020 Share Posted March 23, 2020 (edited) Hi, I created a group of points, then feed all points in a point wrangle, set the group but the code, which moves points, keeps running over all the points, not only the ones in the group? I'm running following as a test: for (int ptnum = 0; ptnum < @numpt; ptnum++) { vector P = point(0, ‘P’, ptnum); P.z += 1; setpointattrib(geoself(), ‘P’, ptnum, P); } My guess is using ptnum overwrites the group selection? Edited March 23, 2020 by waltt Quote Link to comment Share on other sites More sharing options...
Atom Posted March 23, 2020 Share Posted March 23, 2020 (edited) There is no need to run over all the points. At the top of the wrangle, you can simply choose the group you have already created and run over only those points. That entire block of code can be reduced to a single line, if you run your wrangle over points. @P.z += 1; Edited March 23, 2020 by Atom Quote Link to comment Share on other sites More sharing options...
waltt Posted March 23, 2020 Author Share Posted March 23, 2020 Thanks, that fixed the issue too.. I'm completely new to scripting and vex. Thank you. So i guess the loop i created inside of the wrangle overwrites the group selection? Quote Link to comment Share on other sites More sharing options...
Atom Posted March 23, 2020 Share Posted March 23, 2020 Your loop does nothing to change groups. What it actually does is loop over every single point, for every single point (slow). Thus your resulting P.z is always going to be the 1+ the z value of the last point. NOTE: You can't change a point value in VEX, then loop over and fetch it again (other languages, yes. Houdini VEX, no). VEX supplies a pool of points upon entry, evaluates the change, and revises the pool of points upon exit. You typically don't need loops inside of wrangles unless your are running in Detail mode (which means execute this code only one time). Quote Link to comment Share on other sites More sharing options...
waltt Posted March 26, 2020 Author Share Posted March 26, 2020 Thank you very much Atom, this has been very helpful. Your link page as well! Thx!! 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.