Jump to content

How to create a new entry in a tuple detail attribute?


Recommended Posts

When a Houdini HDA is loaded in the Maya plugin, the geometry inputs come in with two string tuple detail attributes, "maya_uv_mapped_uv" and "maya_uv_name", each of the same length. Each member of the first tuple corresponds to the vertex attribute name for the uv sets that Houdini creates when the geometry comes in, i.e. "uv", "uv2", "uv3", etc. Each member of the second tuple is what that name was in Maya for the corresponding uv set in the first tuple. If those are maintained, the geometry output still has the correct uv set when it comes out to Maya, with one strange caveat: the second entry is wiped. Just the second entry. The first and third+ are maintained.

I'm trying to make a workaround for this: if there are two or more uv sets, make a new member of both tuples, copy the second member to the new member, and nuke the second member from orbit just to be sure. I just can't seem to figure out how to make a new member of the tuples. I can't even really figure out how to make a tuple attribute at all, or modify anything but the first member of the tuple. I can copy the contents of the tuple into a string array, and I can make string array detail attributes, but they don't read the same (there is one entry with all members of the array in a list, rather than an individual numbered entry for each member). I don't really see anything relating to them in the documentation, either. Can someone please point me in the right direction?

Link to comment
Share on other sites

  • 1 year later...

Just wanted to chime in, since I spent a little bit figuring this out. (Or at least something similar)

Sometimes there are detail attributes in the geometry spreadsheet that look like:

boneCapture_pCaptData:  [ (0.0, 0.0, 0.0, 0.0, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0) ]

This is a bit odd because there doesn't seem to be either an attribute tuple type in Houdini, or multidimensional arrays. What's happening under the hood (I think) is that every detail array attribute has a "tuple_size" argument. See the python API:

addArrayAttrib(type, name, data_type, tuple_size=1) → hou.Attrib

This defaults to 1, but if it's set to something else (5 in the above case), then Houdini will show the single-dimensional array as an array of tuples of that size. This means that the array must be set to values that are a multiple of tuple_size! 

So if we want to make a new attribute like this, we can do (in Python):

geo.setGlobalAttribValue("myNewTupleArray", [0.0, 0.0, 0.0, 0.0, 0.0,   0.0, 0.0, 0.0, 0.0, 0.0 ])

Reading is similar:

print(geo.floatListAttribValue("myNewTupleArray"))

Just treat it like a normal array, that happens to be shown as a tuple in the editor.

Edited by kleptine
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...