Attrib of size n VS actual attrib array

   1297   6   1
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Hello,

I have few questions regarding array handling. Please refer to the reference image.
  1. What's the difference between A and B attribs?
  2. Which one is more efficient to use when you handle huge arrays?
  3. How to access B entries in VEX? I noticed that some TOPs nodes create this kind of attributes on Geometry, and I don't know how to deal with them.
  4. What's the purpose of setting a qualifier for an attribute?
  5. In the ‘attrib create’ documentation page, under “size” parameter I read the following note:
    For arrays, this specifies the tuple size of the array, not the number of entries of the array. A value of 3 for a float array will thus make a vector array.
    It seems suggesting that you could have a multi-dimensional array, but I know that they are not actually supported. So what does it really mean? I'm confused

thanks for any help!

cheers

Attachments:
arrays.JPG (25.6 KB)

User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
regarding question 3), how to access such attributes in vex, I noticed that the detail expression function on a parameter would read it without problem, while the corresponding vex function would not, being the third argument of the function always ignored, as written on the documentation.

So a summary of what I understood so far:
You can access the attribute “B” with
p@B[n]
only up to the fourth component.
You can access entries with an id bigger than 3, only if you do a bridging with a paramater hscript expression, BUT that's not very ideal and procedural if you have a big array.

Is this correct?
Edited by Andr - July 10, 2019 14:54:46
User Avatar
Member
2041 posts
Joined: Sept. 2015
Offline
A is an attribute of an array of ints( which can vary in size to the max that the combination of Houdini and OS allows).

B is a vector4 attribute, which has 4 components and cannot be expanded upon, i.e. it can't have more than 4 components because it would no longer be a vector4.

To access the vector4 you can do the same as with a vector, i.e. x,y,z but in this case you use w for the forth.

B.x = 1;
B.y = 2;
B.z = 3;
B.w = 4;

Useful vex functions especially when working with matrices(which will have their components vertical in the spreadsheet like your example) are:

set()
setcomp()
getcomp()
assign()
Edited by BabaJ - July 10, 2019 15:54:00
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
hello Babaj,
thanks for taking some time for explaining.

As the picture shows, B in this case is not a vec4, as it's been created with size of 5; as you suggested, it's impossible to access the fifth component with vex.

But I've just found out you can do it with python: you can read and write to components greater than 4.
So it's definitely a Vex specific limitation
User Avatar
Member
2041 posts
Joined: Sept. 2015
Offline
Ok..sorry about this…glazing over what it was.

But still, being listed vertically like that, and that you said it was created with TOPS.

Likely a special attribute for Tops alone.(I don't see any 5 component types in the docs).

But you should still be able to access it with vex. Did you not try setcomp or getcomp?

They use index values to access the specific component.
Edited by BabaJ - July 11, 2019 08:57:58
User Avatar
Member
2041 posts
Joined: Sept. 2015
Offline
Yeah…would be nice to know why there is this ‘limit’ for accessing such attributes.

It's actually nothing new…here's a thread that is basically talking about the same thing

https://www.sidefx.com/forum/topic/44766/?page=1#post-235606 [www.sidefx.com]

I pulled up a hip to see if I can get the same attribute but did not, I did see a 5 component varmap attribute though.

Similar situation, can access the first component but not the rest.

Seems bizarre that there is this ‘limitation’ in accessing the data on some attributes.

But perhaps these are ‘special attributes’ that are not directly tied to geometry; More like a ‘workflow’ element, hence can be accessed with python/hscript. But are shown in spreadsheet anyways for convenience.

I did a search on varmap which seems to have been around and used for some time now. Maybe someone knows something about that and has the same sort of context as your ‘B attribute’.

Curious to know if you run attribtype on ‘B’, what the result is.
Edited by BabaJ - July 11, 2019 10:08:55
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Hey, sorry for the confusion regarding TOPs.
I wrongfully assumed that a Topnet would serialize and display ALL the workitems detail attribs in its geometry spreadsheet. Example for a 2 workitems Topnet with a detail vector attrib:
myVec[0], myVec[1], myVec[2], myVec[3], myVec[4], myVec[5]
where the last 3 items would belong to the 2nd workitem, and you just need to know the size of the attrib to assign the corresponding workitem index.
So that's why I was a bit scared of a potential endless mess in my detail spreadsheet.
That's not the case actually, the Topnet will only merge detail attribs of each workitem into a single one. So I guess you can't have more than 4 components per attribute with TOPs.
Edited by Andr - July 12, 2019 03:02:43
  • Quick Links