Attrib Wrangle: Modify another Points Position

   6250   9   1
User Avatar
Member
101 posts
Joined: Dec. 2012
Offline
Is there an easy way to modify the values of other Points within an attrib wrangle? Fetching Point information is straight forward, but i didn't see any example for modifying neighboring point data. At the same time, i know that what vex makes fast is, when it's locally independent.

Anyhow would be nice to see if its possible.
User Avatar
Member
459 posts
Joined: Oct. 2011
Offline
Hi
I'm not sure what you want to do exactly but it sounds like pcopen is your freind: http://www.sidefx.com/docs/houdini15.0/vex/functions/pcopen [sidefx.com]

-b
http://www.racecar.no [www.racecar.no]
User Avatar
Staff
6205 posts
Joined: July 2005
Offline
I'd recommend setpointattrib
http://www.sidefx.com/docs/houdini15.0/vex/functions/setpointattrib [sidefx.com]

Note that your edits only take effect *after* VEX has been applied to all points. This is to try and keep things fast despite setpointatrib() no longer being a local modification.
User Avatar
Member
101 posts
Joined: Dec. 2012
Offline
Thanks Jeff,
yeah that was what i expected, as i am doing an iterative algorithm, i need the values to be updated every iteration. Its not well suited for parallelisation.
User Avatar
Member
101 posts
Joined: Dec. 2012
Offline
Is there anything other then the foreach sop, to iterate over points and update after every iteration?
User Avatar
Staff
6205 posts
Joined: July 2005
Offline
Probably a lot faster to just put a Attrib VOP/Wrangle into “Detail Mode” and put the for loop inside of there. You can build an array to store all the intermediate values, and write them all out with setpointattrib() when done.

This does lose a huge amount of the benefit of VEX, however. The best is if you can somehow re-think your algorithm to use parallel applications. Often a slower algorithm may end up faster due to the ability to parallelize & get cache coherence.
User Avatar
Member
101 posts
Joined: Dec. 2012
Offline
Hey Jeff, i've never used the Detail attribute before in combination with Attribwrangle, could you provide a minimal example? Would you use the attribwrangle just to store the values in an array or to set it as well?

I have to set a connected points Position while iterating.

Thanks
User Avatar
Staff
6205 posts
Joined: July 2005
Offline
Here is a simple example to add one to every point position in Run Over:etail (only once) mode.

for (int ptnum = 0; ptnum < @numpt; ptnum++)
{
vector P = point(0, ‘P’, ptnum);
P += 1;
setpointattrib(geoself(), ‘P’, ptnum, P);
}
User Avatar
Member
36 posts
Joined: May 2016
Offline
I want set up x position of the point.
Can somebody say why

setpointattrib(geoself(), ‘P.x’, ptnum, P);

didn't work. We have to pass vector to the function?
What to do when we want change only one axis?
User Avatar
Member
8554 posts
Joined: July 2007
Offline
TheCrisis
…We have to pass vector to the function?
What to do when we want change only one axis?
yes, you have to pass new attribute value, so if it's a vector then full vector
for (int ptnum = 0; ptnum < @numpt; ptnum++)
{
    vector P = point(0, 'P', ptnum);
    P.x = ptnum;
    setpointattrib(0, 'P', ptnum, P);
}
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links