Welcome to od|forum

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

SteveNi

Problem printing attribute value from wrangle node

So I was writing some vex code for a scene Im working on, and while I was debugging the code to correct an issue I placed various printf() functions in the code to check the state of the attributes right after I made some changes to them, and I noticed that if I load an attribute in a variable and print it, modify the attribute, reload it in the same variable and then print the variable out again, it wont show the newer value if the loading&printing process is done in the same wrangle node of where the attribute was modified.

Here's an example scene wich exactly recreates my scenario.

Am I missing something stupid here?

 

Test_attribute.hipnc

Edited by SteveNi

Share this post


Link to post
Share on other sites
//Reload it and print it out again
attribute = attrib(0, "primitive", "attribute1", 50);

It will fetch attribute value from first input (original geometry) again. You need to store values in variables.

1 person likes this

Share this post


Link to post
Share on other sites
12 hours ago, f1480187 said:

//Reload it and print it out again
attribute = attrib(0, "primitive", "attribute1", 50);

It will fetch attribute value from first input (original geometry) again. You need to store values in variables.

Oooooh thats true, thanks!

 

EDIT:

Is there anyway to load the current status of the attributes, apart from keep track of the changes in variables??

I tried to use geoself, just to be sure, but it doesn't work either.

Edited by SteveNi

Share this post


Link to post
Share on other sites

if you want to check the updated values in the same node that you changed them in,
the only way is to use binding:

printf("%d\n", @attribute1); // prints old value
@attribute1 = 1337; //new value
printf("%d\n", @attribute1); // prints new value

//setprimattrib(0, "attribute1", @primnum, 1337); 
// will only be applied AFTER the node is cooked, not internally, so you can not fetch the value afterwards.
// this is done with regards to "parallelizability" as with setprimattrib() you could potentially adjust the value of of a different primitive than itself,
// that becomes problematic if multiple calls of the code try to adjust the same primitive attribute.

/*
/////////////////////////another option:
float currentValue = prim(0, "attribute1", @primnum);
printf("%d\n",currentValue); // prints old value
currentValue = 1337; //new value
printf("%d\n",currentValue); // prints new value
setprimattrib(0, "attribute1", @primnum, currentValue);
*/

Note that with binding, you can only load and write attributes of the same class that the wrangle is running in currently (the "run over" parameter)
so running over points, you will load and write point attributes with bindings for example.

Edited by acey195

Share this post


Link to post
Share on other sites
7 hours ago, acey195 said:

if you want to check the updated values in the same node that you changed them in,
the only way is to use binding

Yea you are right, the problem here is that I need to load the attribute for a specific primitive, thats why I used the primitive() function.

Guess I'll have to use another method.

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