Setting Point Attribute in Vex

   16874   4   1
User Avatar
Member
2164 posts
Joined: Sept. 2015
Offline
Hi,

I was wondering if anyone knows if it's possible to set one component of a points attribute with only the setpointattrib function in vex like for y with ( my attempt which does not work):

setpointattrib(geoself(), "P.y", Point_Num, New_Point_Value_Y, "set");

It seems I would have to make a vector and use the getattrib function to “fill” that vector with the points xyz values then just change that vectors y and use the changed vector in the setpointattrib function with “P” instead of “P.y”

This is in a for loop of a detail( only once ) vex conext.

If this was a running over points context I believe I could just apply created vector with = @P and just change that vectors y component, then use it.

But still in either case, I still have to do previous steps instead of directly using setpointattrib with P.y

Or so I think?
User Avatar
Member
9380 posts
Joined: July 2007
Offline
correct, you need to get the whole vector first using point() function, modify .y component and then setpointattrib()

EDIT: if you wanna cheat and I'm not sure if it'll be faster
since you are obviously trying to avoid reading the position in detail wrangle, therefore you are not using it there for anything and you can modify the y component beforehand as it will be replaced anyways
so you can have pointwrangle before:
@P.y = 0;
then in your detail wrangle you will just do:
...
setpointattrib(0, "P", Point_Num, set(0, New_Point_Value_Y, 0), "add");
...
which will add 0 to .x and .z component so will not change them
and will add New_Point_Value_Y to .y component which was reset to 0 so it will become just New_Point_Value_Y value
Edited by tamte - March 15, 2017 12:44:09
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
2164 posts
Joined: Sept. 2015
Offline
Yeah…I don't mind using the getattrib/point function and I had no real need to do it otherwise.

But I was curious if it could be done with just one line of code.

And that's a ‘cool’ trick.

If I really gave the docs on the set function a careful run over especially in this case with the “add” argument…I should have thought of that. But I didn't.

So, thanks Tomas for pointing this out to me…again Cool!
Edited by BabaJ - March 15, 2017 13:46:06
User Avatar
Staff
6793 posts
Joined: July 2005
Offline
Another ugly trick is to zero out the y with a multiply first:

setpointattrib(0, "P", Point_Num, set(1, 0, 1), "multiply");
setpointattrib(0, "P", Point_Num, set(0, New_Point_Value_Y, 0), "add");
User Avatar
Member
2164 posts
Joined: Sept. 2015
Offline
Ugly?…lol…I think it's pretty good…these points, pun not intended, are helping me become more agile in dealing with points/data in Houdini.

Thanks.
  • Quick Links