Array attribute to Vex variable

   11033   5   1
User Avatar
Member
3 posts
Joined: Aug. 2018
Offline
So for some reason, despite the Test attribute being an array with multiple entries, this just results in an empty array:

string Tiles=vertex(0,“Test”,0);

Is there some trick to transferring arrays from attributes to variables?
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
s[]@test = {"one", "two", "five"};
string myVar[] = @test;
s[]@test2 = myVar;

this is working for me..
maybe post a hip file reproducing the error.
Edited by Andr - July 4, 2019 14:20:40
User Avatar
Member
3 posts
Joined: Aug. 2018
Offline
Hmm, thanks so much, that works for me too. However, as best I can tell, it doesn't work when I use the vertex function to access an array vertex attribute from inside a detail wrangle. That or I'm doing something silly somewhere and totally failing to notice.

Here's the problem isolated as best I can; it just prints “Test={}”:
s[]@Test={"k","g"};

string Test2[]=vertex(0,"Test",0);

printf("Test=%s",Test2);

Here's the .hip, with both the original context and it isolated out into a wrangle with just that code:

Attachments:
WaveformCollapse.hip (67.5 KB)

User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
hey, I'm not sure what you're trying to read with
vertex(0,"Test",0);

I mean, you are trying to read a non-existent vertex attribute “Test”.
But you are in the Detail Wrangle, the “test” attribute that you create is a detail attribute. You should ask for a detail attrib instead.
BUT be aware: if you change it to detail(0,“Test”,0) it won't work as well because you are trying to access a non-existent detail attribute now, hehe. Why so?
When you use “0” as first argument of the point(), prim(), detail() functions you are just using a placeholder for the path of the immediate upstream node. It's like you are asking for the attribute TEST in the upstream node, which of course it doesn't exist, as you create the “test” attribute only later in the wrangle.

Anyway, you do the same thing in the “Collapse” node. You are trying to read a non existent “PossibleTile” vertex attrib.
You should instead use the point() function, instead of vertex(), because PossibleTile is a point attrib.
In this case you can use the point() function because PossibleTile attrib is already existent the in previous node that you are trying to access.



cheers
Edited by Andr - July 5, 2019 16:59:36
User Avatar
Member
396 posts
Joined: Nov. 2016
Online
Hey Meloncov, I noticed your PossibleTile is a point attribute, but you use the vertex() function to retrieve it. point() should work.
User Avatar
Member
3 posts
Joined: Aug. 2018
Offline
Andr
hey, I'm not sure what you're trying to read with
vertex(0,"Test",0);

I mean, you are trying to read a non-existent vertex attribute “Test”.
But you are in the Detail Wrangle, the “test” attribute that you create is a detail attribute. You should ask for a detail attrib instead.
BUT be aware: if you change it to detail(0,“Test”,0) it won't work as well because you are trying to access a non-existent detail attribute now, hehe. Why so?
When you use “0” as first argument of the point(), prim(), detail() functions you are just using a placeholder for the path of the immediate upstream node. It's like you are asking for the attribute TEST in the upstream node, which of course it doesn't exist, as you create the “test” attribute only later in the wrangle.

Oh, right, of course. I was trying to reproduce the problem as simply as possible, but I just made a new problem. As you said, the actual problem was point vs. vertex. Thanks so much to both of you!
  • Quick Links