According to the docs, I should be able to use the
MFnAttribute.setWorldSpace with addNodeDirtyPlugCallback to create a
callback for an attr that gets triggered whenever a change in the
hierarchy that affects the worldSpace transformation happen. But, when
I do this in my command plug-in it does not work! Am I doing something
wrong or is this a BUG?
# A shape node I want to monitor when its worldMatrix attr changes,
which I’ll do by creating
# a worldSpace attr that will get marked dirty when a transformation
is applied above
name = ‘|SpotLight1|SpotLightShape1’
list = OpenMaya.MSelectionList()
list.add(name)
nodeMObj = OpenMaya.MObject()
list.getDependNode(0, nodeMobj)
typedAttrFnSet = OpenMaya.MFnTypedAttribute()
typedAttrObj = typedAttrFnSet.create(’test’, ‘tst’,
OpenMaya.MFnData.kMatrix)
typedAttrFnSet.setCached(0)
typedAttrFnSet.setReadable(1)
typedAttrFnSet.setWritable(0)
typedAttrFnSet.setConnectable(1)
typedAttrFnSet.setHidden(0)
typedAttrFnSet.setArray(1)
typedAttrFnSet.setStorable(0)
typedAttrFnSet.setKeyable(0)
typedAttrFnSet.setWorldSpace(1)
typedAttrFnSet.setUsesArrayDataBuilder(1)
dgModifier = OpenMaya.MDGModifier()
dgModifier.addAttribute(nodeMObj, typedAttrObj,
OpenMaya.MFnDependencyNode.kLocalDynamicAttr)
try:
dgModifier.doIt()
except:
print “doIt failed”
------------------------
# Checking the attr I get
import maya.OpenMaya as OpenMaya
list = OpenMaya.MSelectionList()
list.add(’|rexSpotLight1|rexSpotLightShape1’)
node = OpenMaya.MObject()
list.getDependNode(0, node)
nodeFn = OpenMaya.MFnDependencyNode(node)
attrMObj = nodeFn.attribute(’test’)
attrFn = OpenMaya.MFnTypedAttribute(attrMObj)
print attrFn.isCached()
print attrFn.isReadable()
print attrFn.isWritable()
print attrFn.isConnectable()
print attrFn.isHidden()
print attrFn.isArray()
print attrFn.indexMatters()
print attrFn.isStorable()
print attrFn.isKeyable()
print attrFn.isWorldSpace()
print attrFn.usesArrayDataBuilder()
print attrFn.attrType() == OpenMaya.MFnData.kMatrix
True
True
False
True
False
True
True
False
False
True
True
True
So the attr isArray and isWorldSpace, but is not triggering my
callback method when it is set dirty.. The only thing I can think of
is that this can only be done with static attrs in a node
initialization. But, I didn’t see this in the docs. Is it implied? I
would greatly appreciate your help here. It’s driving me crazy :-(
Ryan Heniser
Double Negative
R&D Software Engineer