I should probably be more specific: I'm back to my mocap project that I haven't looked at in a while, but have decided to come back to. Some good advice on this board several months back pointed me in the direction of MTimerMessage
his advice was to create a callback that would dirty the input plug of the compute, which I tried, but couldn't quite get to work. The other was to set the value directly to the output plug, but I've struggled with that as well....(see the pattern?) Anyway, it's a bit frustrating because I receive the values from my device no prob, but I can't simply pipe these values to an attribute on my node. does that help or just confuse things? On Wed, Jan 28, 2009 at 11:17 PM, Hradec <[email protected]> wrote: > You can use: > > OpenMaya.MDGMessage.addNodeAddedCallback ( nodeInitializeCallback, > nodeTypeName) > > where nodeInitializeCallback is a python function and nodeTypeName is a > string with the type name. > > The nodeInitializeCallback will be called allways after the node is > created, so you can mess with its attributes as you please... > > I use it in SLUM (my shader management project) as a method of my node > class to initialize attributes in the node according to a shader template > file... you can find my source code at: > > http://code.google.com/p/slum/ > > look into /trunk/python/slumMaya/nodeFactory.py and > /trunk/python/slumMaya/shaderBase.py. NodeFactory is the one who uses > OpenMaya.MDGMessage.addNodeAddedCallback, and the function it executes is > defined in shaderBase. > > also, this is the maya api help page on the MDGMessage.addNodeAddedCallback > method... > > > http://download.autodesk.com/us/maya/docs/Maya85/API/MDGMessage.html#DOC.53.7.3 > > let me know if it works! =) > > -H > > > On Wed, Jan 28, 2009 at 8:33 AM, npuckett <[email protected]> wrote: > >> >> Ok, >> So I'm working on a plugin at the moment and I have found out (see: >> someone with more experience with this than me told me..) that I need >> to set the value to an attribute on the node I'm creating directly >> rather than using a compute. What I need some help with is the >> general syntax of how to do this sort of thing. For example: >> >> class testNode(omMPx.MPxNode): >> # input and output variables >> MYATTR = om.MObject() >> >> >> def someFunction() >> ...do some stuff >> ...set the value of MYATTR on testNode during runtime >> >> >> def nodeInit(): >> numAttr = om.MFnNumericAttribute() >> testNode.MYATTR = numAttr.create >> ("myAttr","my",om.MFnNumericData.kFloat,0.0) >> numAttr.setStorable(1) >> numAttr.setWritable(1) >> >> testNode.addAttribute(testNode.MYATTR) >> >> >> I hope that explains it enough and thanks for any help that can point >> me in the right direction >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ Yours, Maya-Python Club Team. -~----------~----~----~----~------~----~------~--~---
