When iterating over nodes in a Maya scene (multiple geometries on multiple assets), I am setting blendShape targets as follows:
pm.blendShape(blendshape, edit=True, target=(mesh, target_index, corrective, 1.0))
Sometimes it works, at other times I get the following error:
Object will not allow alias 'corrective_name' to be set. Possibly because an attribute of that name already exists.
...where corrective_name is the name of the nt.Transform corrective
. I cannot find an attribute with that name on the blendshape
node, so that can't be the reason. Forcing the value of corrective
to random nonsense (in an attempt to guarantee that there isn't a clash), leads to the same error.
What are other causes of this failure?
Note: A visible side-effect (or cause?) is that on blendShapes where the call is working, I can see weights with names matching the corrective names. On blendShapes where the call fails, the weights are called weight[0]
, weight[1]
, weight[2]
and so on.
Note 2: It seems like (some) attribute aliases fail after the .ma file is saved and then loaded for the first time. The weight attributes on certain objects appear as weight[0]
instead of actualName
after loading. The same object fails consistently (aliases for attributes on that object always fail, aliases on other objects never fail). This means that the pm.blendShape
succeeds on that object in the first session, but fails every time after the scene is loaded. Newly created attributes are then called weight[X]
too. (Example of alias failure in a completely different context.)
This doesn't happen if an asset (which contains multiple objects) is imported into the scene, only if it is referenced.
Asset alias working (on first creation, and when asset imported):
Asset alias failing (when asset referenced and saved scene is loaded for the first time):