Have you set up the node's attribute dependencies? On Fri, Aug 13, 2010 at 9:04 AM, susanta <susant...@gmail.com> wrote:
> No luck :(. tried to connect currentChainLength (which is the output > of my node) to another locator's tx plug....only get evalution once > (opening file, or selecting my node in Attribute editor....i.e. > external querry to worldMatrix plug)...here is the rough test code... > > class ChainLengthCalc(omx.MPxNode): > kPluginNodeTypeName = "ChainLengthCalc" > kPluginNodeTypeId = om.MTypeId(0xd1a9257) > evalIndex = 0 > def __init__(self): > omx.MPxNode.__init__(self) > > def compute(self,plug,dataBlock): > if plug == self.currentChainLength: > print "hello" > ChainLengthCalc.evalIndex+=1 > currentLength = ChainLengthCalc.evalIndex > ##self._getChainLength() > outHandle = > dataBlock.outputValue(self.currentChainLength) > outHandle.setMDistance(om.MDistance(currentLength)) > dataBlock.setClean(self.currentChainLength) > 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(True) > 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) > > On Aug 13, 4:20 pm, Chad Vernon <chadver...@gmail.com> wrote: > > You need to have the output connected to something or else Maya will > never > > request a node compute. It only calculates nodes when it needs to. You > > should be able to just use the worldMatrix just fine. > > > > Chad > > > > On Fri, Aug 13, 2010 at 8:11 AM, susanta <susant...@gmail.com> wrote: > > > "worldmatrix is only updated on demand.." > > > > > Yea, That also I have speculated... > > > > > "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." > > > > > My problem is little bit typical :). this is not about computing world > > > matrix...say like, my node is connected in this order: NodeA -> NodeB- > > > > NodeC->.......-> NodeD->MyNode. Now what I want to achieve, instaed > > > of using any callback system use DAG system, to evalute myNode's > > > compute block while any of the node in the hierarchy is changing > > > trasform matrix. Now if I plugin parentmatrix / matrix from nodeD, I > > > think if nodeD is affected then only it will evalute mynode....but not > > > for other nodes up in the hierarchy. So to find a clean way I have > > > tried to use worldMatrix of NodeD (as worldMatrix change is true for > > > change in any depth) as I not want to plug with all other node's > > > matrix in the hierarchy. But seems like I'm wrong :(...need to find a > > > better solution. Any way thanks man. > > > > > On Aug 13, 3:10 pm, Adam Mechtley <adam.mecht...@gmail.com> wrote: > > > > 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 > > > > > > -- > http://groups.google.com/group/python_inside_maya > -- http://groups.google.com/group/python_inside_maya