Vex setattrib() not updating.. kind of...

   1129   1   1
User Avatar
Member
4 posts
Joined: July 2014
Offline
I'm playing about with vex at the moment.

I have a question re copy to points SOP and VEX trying to target and manipulate individual copies.

Lets say the pscale of copy ID3 is 2.5 to begin with..


// SET THE SCALE OF OBJECT ID3 to 10
setattrib(0, ‘point’, ‘pscale’, 3, 0, 10, ‘set’);

The geometry spreadsheet now states pscale = “10” and the geo in the scene view is indeed 10 units.

float myscale = attrib(0, ‘point’, ‘pscale’, 3);
printf('%f', myscale);

But this print function still shows “2.5"

What am I doing wrong?

thanks
User Avatar
Member
209 posts
Joined: March 2018
Offline
It's true!
When you try to read attribute with attrib function it reads attribute from first input which pscale is still 2.5.
If you want to access the latest version of changes in the same node you can do this for instance:
if (@ptnum == 3)
{
    f@pscale = 10;
    printf("%f", f@pscale);
}
Also this code runs faster than calling attrib and setattrib which are run-time functions…
  • Quick Links