Register specific node type created

61 views
Skip to first unread message

Arvid Schneider

unread,
Aug 6, 2015, 6:00:17 PM8/6/15
to Python Programming for Autodesk Maya
How would I create a callback that fires when a specific node type is created?
I know about: MDGMessage.addNodeAddedCallback( function )
but that registers any node created. I want to limit that. 
Someone an idea?
Arvid

Ravi Jagannadhan

unread,
Aug 6, 2015, 6:02:38 PM8/6/15
to python_in...@googlegroups.com
Filter in the callback for your specific node type?

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/62af34c5-03e1-4064-86c3-76e11df510b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Where we have strong emotions, we're liable to fool ourselves - Carl Sagan

Arvid Schneider

unread,
Aug 6, 2015, 6:05:37 PM8/6/15
to python_in...@googlegroups.com
That doesnt work..
MDGMessage.addNodeAddedCallback( newNodeCB, 'directionalLight')
what is the proper syntax?


For more options, visit https://groups.google.com/d/optout.



--
Arvid Schneider
Look Develpopment | Lighting TD | Show TD
www.arvidschneider.com

Mobil DE: (+49) 170 321 0074
Mobile UK: (+44) 744 824 6973

Kurian O.S

unread,
Aug 6, 2015, 6:05:52 PM8/6/15
to python_in...@googlegroups.com

MCallbackId MDGMessage::addNodeAddedCallback ( MMessage::MNodeFunction func,
const MString & nodeType = "dependNode",
void * clientData = NULL,
MStatus * ReturnStatus = NULL  
)

Parameters:
[in] nodeType Type of node that will trigger the callback
[in] clientData User defined data passed to the callback function
[out] ReturnStatus status code


There is a nodeType argument so that will help you to get what you trying.


For more options, visit https://groups.google.com/d/optout.



--
--:: Kurian ::--

Arvid Schneider

unread,
Aug 6, 2015, 6:07:31 PM8/6/15
to python_in...@googlegroups.com
Thats exactly what I did. I get an error, TypeError: MDGMessage_addNodeAddedCallback() takes no keyword arguments //


For more options, visit https://groups.google.com/d/optout.



--

Kurian O.S

unread,
Aug 6, 2015, 6:11:48 PM8/6/15
to python_in...@googlegroups.com
def testFooMain(*args, **kwargs):
    print "Foo"

MDGMessage.addNodeAddedCallback(testFooMain, "directionalLight")


//Foo


For more options, visit https://groups.google.com/d/optout.



--
--:: Kurian ::--

Arvid Schneider

unread,
Aug 6, 2015, 6:13:55 PM8/6/15
to python_in...@googlegroups.com
I just restarted maya..now everything works as expected! Thanks Kurian for the quick help!


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages