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.
-~----------~----~----~----~------~----~------~--~---

Reply via email to