Jump to content

Cannot access attribute of point inside the wrangle in which it is created


Recommended Posts

Wondering why this behavior exists:

I create a bunch of points in a Detail wrangle using this code.  After the loop, when trying to print the value of any point attribute, it always returns {0,0,0}.
If I wire in a second wrangle and try to print the value using the same last two lines of code, the P vector prints correctly.
What is the logic behind this? 

 

int i;
for (i=0; i<100; i++){
float x = rand(i);
float y = rand(i*2);
float z = rand(i*3);
vector v = set(x,y,z);
addpoint(geoself(), v);
}

vector val = point(geoself(), "P", 5);
printf("%g", val);

 

Edited by JH12
Link to comment
Share on other sites

Because the geometry creation happens after the entire VEX code is executed and the result is finalized as the output of that particular wrangle. So you don't have those geometry actually created while you are still in the same VEX kernel, but after. That's why you can't use them in the same code that used to create them.

Link to comment
Share on other sites

On 7/14/2022 at 3:49 PM, JH12 said:

Thanks, and why is this?

i was stumped for while when i first ran into this.. think of it like this..

 

your wrangle works on input 0. and input 0 doesn't have the points... you are querying . as simple as that .

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...