58 import maya.OpenMaya
as OpenMaya
59 import maya.OpenMayaMPx
as OpenMayaMPx
61 kPluginCmdName =
"spParentAddedMsg"
66 def removeCallback(id):
70 sys.stderr.write(
"Failed to remove callback\n" )
73 def dagParentAddedCallback( child, parent, clientData ):
74 print(
"dagParentAddedCallback...")
75 print(
"\tchild %s" % child.fullPathName())
76 print(
"\tparent %s" % parent.fullPathName())
77 print(
"\tclient data %s" % clientData)
79 def createParentAddedCallback(stringData):
85 sys.stderr.write(
"Failed to install dag parent added callback\n" )
92 class scriptedCommand(OpenMayaMPx.MPxCommand):
94 OpenMayaMPx.MPxCommand.__init__(self)
95 def doIt(self,argList):
98 print(
"Message callaback already installed")
100 print(
"Installing parent added callback message")
101 messageId = createParentAddedCallback(
"_noData_" )
105 return OpenMayaMPx.asMPxPtr( scriptedCommand() )
108 def initializePlugin(mobject):
109 mplugin = OpenMayaMPx.MFnPlugin(mobject)
111 mplugin.registerCommand( kPluginCmdName, cmdCreator )
113 sys.stderr.write(
"Failed to register command: %s\n" % name )
117 def uninitializePlugin(mobject):
120 removeCallback( messageId )
122 mplugin = OpenMayaMPx.MFnPlugin(mobject)
124 mplugin.deregisterCommand( kPluginCmdName )
126 sys.stderr.write(
"Failed to unregister command: %s\n" % kPluginCmdName )