SteveNi Posted April 22, 2017 Share Posted April 22, 2017 (edited) 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 April 22, 2017 by SteveNi Quote Link to comment Share on other sites More sharing options...
f1480187 Posted April 23, 2017 Share Posted April 23, 2017 //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 Quote Link to comment Share on other sites More sharing options...
SteveNi Posted April 23, 2017 Author Share Posted April 23, 2017 (edited) 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 April 24, 2017 by SteveNi Quote Link to comment Share on other sites More sharing options...
acey195 Posted April 25, 2017 Share Posted April 25, 2017 (edited) 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 April 25, 2017 by acey195 Quote Link to comment Share on other sites More sharing options...
SteveNi Posted April 25, 2017 Author Share Posted April 25, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.