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
On 6 May, 11:02, Ryan <[email protected]> wrote:
> Chad,
>
> Thanks for the response.
>
> Will Maya trigger a callback method added with
> addNodeDirtyPlugCallback on the shape node after I call the
> setWorldSpace func/method on the shape node's '.worldMatrix' attr?
>
> Ryan
>
> On 5 May, 17:37, Chad Vernon <[email protected]> wrote:
>
>
>
> > If you create an array attribute with MFnAttribute::setWorldSpace, then it
> > will get marked dirty when the world transform changes.
>
> > Chad
>
> > On Wed, May 5, 2010 at 9:24 AM, Ryan <[email protected]> wrote:
> > > What's the best way to monitor a shape node's transformations? I'd
> > > like for Maya to call a callback method whenever the world matrix
> > > attribute changes on a specific shape node. I've tried both
>
> > > addNodeDirtyPlugCallback
> > > addAttributeChangedCallback
>
> > > from MNodeMessage. But, neither will make calls when the transform
> > > node for the shape node undergoes a transformation.
>
> > > Thanks,
> > > Ryan
>
> > > --
> > >http://groups.google.com/group/python_inside_maya
>
> > --http://groups.google.com/group/python_inside_maya
>
> --http://groups.google.com/group/python_inside_maya
--
http://groups.google.com/group/python_inside_maya