I'm trying to get a list of attributes and their type. However, arrays and matrix attributes don't work; only floats, ints and strings are returned by fooAttr.dataType().
I found a workaround for my specific need, but I decided to experiment with inlinecpp. But I can't figure out how to get the name and type of an attribute using the HDK. Anyone have some tips on how I could print out, as an example:
It's nice to see people occasionally have use of my repo!
So how Houdini stores attribute type info varies based on what the data is. For example, when we talk about an attribute being a matrix or quaternion, really this just means that the attribute is of N size (9 or 16 for matrix, 4 for quaternion, etc) and then Houdini will add additional metadata to that attribute that flags how to treat the data later on. This is stored in the attribute's Options data which you can thankfully access through Python (hou.Attrib.options()). In terms of an array attribute that's not the same kind of thing (it's more than just how to interpret the data). hou.Attrib.isArrayType() can tell you if your attribute is an array or not and you'd then rely on hou.Attrib.dataType() to determine which kind of array (float, int, string) like any other attribute.
Consider the following test of some various attribute types:
I don't have the time to look through the HDK docs and offer an example of how to get the same info from inlinecpp right now, but you can probably check the HDK Geometry Attribute docs for some more info on how things are defined internally and how you could get at that info. http://www.sidefx.com/docs/hdk/_h_d_k__geometry__attributes.html [www.sidefx.com]
Hope that helps!
Edited by graham - April 21, 2018 11:34:43
Graham Thompson, Technical Artist @ Rockstar Games