Iirc, worldmatrix is only updated on demand (eg, you getAttr on it or on a plug 
that depends on it). Try instead hooking up to matrix and parentmatrix plugs of 
the node whose worldmatrix you want. They should get pushed to your node and 
then you can just concatenate them in compute() to get the world matrix.

Sent from my iPhone

On Aug 13, 2010, at 6:44, susanta <susant...@gmail.com> wrote:

> Hi Guys,
> 
> I'm trying to create a custom MPX node, which is doing some
> calculation based on a bone's scale in a hierarchy. So far my compute
> code is working properly. I want to run the compute block always if
> the any bone in the hierarchy got new world matrix (either by pos, rot
> or scale change). But what I'm getting here, worldmatrix attribute of
> a node not getting changed always untill you querry from outside (eg.
> through MEL). Below is my test code....I have a input matrix plug
> which connected to worlMatrix of a tranformNode. I expect when I'm
> scaling or moving position of the transform node...compute block of my
> node should get called...but not getting desired result...am I missing
> somthing?
> 
> Thanks
> Susanta
> 
> class ChainLengthCalc(omx.MPxNode):
>    kPluginNodeTypeName = "ChainLengthCalc"
>    kPluginNodeTypeId = om.MTypeId(0xd1a9257)
>    def __init__(self):
>        omx.MPxNode.__init__(self)
> 
>    def compute(self,plug,dataBlock):
>        if plug == self.currentChainLength:
>            print "hello"
>            return om.MStatus.kSuccess;
>        return m.MStatus.kUnknownParameter;
> 
> 
>    @classmethod
>    def creator(cls):
>        return omx.asMPxPtr( cls() )
> 
>    @classmethod
>    def initialize(cls):
>        unitAttr = om.MFnUnitAttribute()
>        cls.currentChainLength = \
>        unitAttr.create("currentChainLength", "ccl",
>                om.MFnUnitAttribute.kDistance, 0)
>        unitAttr.setKeyable(False)
>        unitAttr.setWritable(False)
>        cls.addAttribute(cls.currentChainLength)
> 
>        mAttr = om.MFnMatrixAttribute()
>        cls.drivingBoneMatrixAttr = mAttr.create( "drivingBoneMatrix",
> "dbm")
>        mAttr.setStorable(True)
>        mAttr.setWritable(True)
>        cls.addAttribute(cls.drivingBoneMatrixAttr)
> 
>        cls.attributeAffects(cls.drivingBoneMatrixAttr,
> cls.currentChainLength)
> 
> 
> -- 
> http://groups.google.com/group/python_inside_maya

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to