Jump to content

Problem printing attribute value from wrangle node


SteveNi

Recommended Posts

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
Link to comment
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
Link to comment
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
Link to comment
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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...