Jump to content

Access array attribute wrangle


Cain&Able

Recommended Posts

Hey, 

 

I have a bunch of points with 3 float attributes,  b[0] b[1], b[2]

 

If I want to access only the second attribute, specifically through a wrangle (for learning), how would I do this? 

 

I've tried

 

@foo = point(@p,"b",1) 

 

but that only returns the first attribute value. Presumably because I'm not asking for an array? 

 

Thanks! 

Link to comment
Share on other sites

3-float is a tuple, not an array. Difference in attribute access:

foo = f[]@attr[1]

versus

foo = v@attr.y
foo = v@attr[1]

They also shows differently in Spreadsheet. Arrays displays as bulk of values inside brackets, tuples have a column per each component. 3-float is an attribute itself, not three attributes, so, if you want second component by retrieving an attribute from points, use constructs like this:

// For vectors, normals, colors, positions, 3-floats.
vector foo = point(0, "b", @ptnum);
float bar = foo.y;

// For float arrays.
float foo[] = point(0, "b", @ptnum);
float bar = foo[1];

But it is just a longer version of @-access syntax. Typically we use point() function when want to access an attribute of some specific point number, not from same point being processed.

  • Like 1
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...