Jump to content
Sign in to follow this  
waltt

Group in point wrangle

Recommended Posts

Posted (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 by waltt

Share this post


Link to post
Share on other sites
Posted (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 by Atom

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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).

Share this post


Link to post
Share on other sites

Thank you very much Atom, this has been very helpful. Your link page as well! Thx!!
 

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
Sign in to follow this  

×