Export custom matrix attribute in Alembic geometry cache

In Maya, I am not able to cache a custom matrix attribute to an Alembic cache of geometry. The Alembic cache and the attribute data is to be used in Katana.

Our surfacing team asked me if I can pass an Arnold UV projection node’s “placementMatrix” attribute to a model’s Alembic cache.

I added a custom matrix attribute to a relevant geometry shape node, and then connected the Arnold UV projection node’s placementMatrix attribute to it. I cached the geometry. To test whether the attribute survived in the cache, I imported it back into Maya. I received a warning:
// Warning: Unsupported attr, skipping: placementMatrix float64_t[16] //

Not supported? Is what I’m trying to do not possible? We tested the cache in Katana and the attribute does not appear, most likely for the same reasons (surfacing artist did not tell me if they received any errors)

PyMel Example. Make sure the Arnold and Alembic plugins are loaded.

from pymel import core

ball = core.polySphere(name='ball', constructionHistory=False)[0]
ballshape = ball.getShape()
attr_name = 'placementMatrix'
ballshape.addAttr(attr_name, dataType='matrix')
proj = core.createNode('aiUvProjection', name='projection1')
proj.placementMatrix.connect(ballshape.placementMatrix, force=True)

path = r"C:\temp\test.abc" # wherever you want, as long as the folder exists
job_str = ("-frameRange 1 1 -attr {attr} -stripNamespaces "
           "-writeColorSets -writeVisibility -writeUVSets -dataFormat " 
           "ogawa -root {node} -file {path}".format(attr=attr_name, 

When the resulting Alembic is imported in Maya, you will see the warning.
Any ideas? Surfacing said they wanted a matrix in Katana. I’m not that familiar with Katana, so I don’t know of any alternatives.

So, I guess the silly question is: if you need to pass a matrix, can you get by with just exporting another transform node? (Don’t worry, I know full well you shouldn’t need to do that, and this is definitely a limitation)

Another workaround could be to just export like normal, then use the python alembic library to add any extra attributes in a second pass.

Here’s a terrible idea: Add 16 double attributes and pass the data like that. (Don’t actually do that)

Hmm… this is an odd one. The Alembic api supports scalar/array matrices specifically:

M44dProperty (each Sample is sixteen 64-bit floating point numbers; extent = 16)

So my hunch might be either Autodesk doesn’t support it or the matrix type of double isn’t supported. Could you try the float matrix attribute type -at fltMatrix?

Thanks for the replies.

@chalk I tried attributeType=‘fltMatrix’ when I initially received the error, sorry I failed to mention that, but thanks! Unfortunately, the result was empty; the attr didn’t show up on the imported alembic (in Maya). I didn’t parse the alembic file itself to inspect whether the attr was stored at all, but in our tests, Surfacing didn’t find that ‘fltMatrix’ attr when they brought the abc into Katana.

@tfox_TD I contemplated deconstructing the matrix and connecting it to a transform, but Surfacing said that they would need to figure out how to handle the projection with a transform instead of a matrix. As I said, I’m not that familiar with Katana, so I don’t know exactly how hard working with that transform might be. Maybe it’s easy? We may end up going this route. Thanks :+1:.

If anyone else can shed some light on this matrix mystery, I’d appreciate it. Surely I’m not the first person to try this. Maybe caching this data as transform is the way to go? Maybe Maya 2020.2 (the version we are using on this project) has a broken Alembic implementation?