Jump to content

Group in point wrangle


waltt

Recommended Posts

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

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
Link to comment
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).

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