I am creating objects and attaching a custom attribute to it in OpenMaya:
nAttr = OpenMaya.MFnNumericAttribute()
myNewScaler.xyz = nAttr.create( "scaleXYZ", "xyz", OpenMaya.MFnNumericData.kDouble, 20.0 )
nAttr.setMin(0.0)
nAttr.setSoftMax(100.0)
nAttr.setKeyable(True)
nAttr.setStorable(True)
What I need to be able to do is when I select an object I need to see if this attribute exists so I can apply values to it.
For some reason I cannot query it, When I list all attributes on the object it gives me the basic nodes:
print cmds.listAttr( )
[u'message', u'caching', u'isHistoricallyInteresting', u'nodeState', ....]
So I won’t be able to query it:
cmds.attributeQuery( 'scaleXYZ', node = obj, exists=True )
Do I have to call something like: “nAttr.registerNodeToMaya()”?! I ask because with the class reference I don’t see: .setKeyable() or .setStorable() http://download.autodesk.com/us/maya/2009help/api/class_m_fn_numeric_attribute.html so I don’t know what else I am missing from the docs, so am I even 'Registering" it to the attributes?
How can I get this attribute node?
Worse case I use:
if '%s.%s' % (attribute, node) != None:
But I would rather stay away from that.