Can some one share examples of custom context tool realisation via python ?
There are a lot of examples on C++ in books and documentation.
But no python scripts. The python scripts i googled are more like a dummy.
Here is a dummy script:
import maya.cmds as cmds
import maya.OpenMaya as om
import maya.OpenMayaMPx as mpx
import sys
pluginCtxName = "CustomContext"
class CustomSelectContext(mpx.MPxSelectionContext):
def __init__(self):
mpx.MPxSelectionContext.__init__(self)
def doPress(self, event):
print ('SHLOOOOOOOOOOOOOOOOMP')
class CommandCreator(mpx.MPxContextCommand):
def __init__(self):
mpx.MPxContextCommand.__init__(self)
def makeObj(self):
return mpx.asMPxPtr(CustomSelectContext())
def initializePlugin(mobject):
mplugin = mpx.MFnPlugin(mobject)
try:
mplugin.registerContextCommand( pluginCtxName, CommandCreator )
except:
print "Failed to register context command: %s" % pluginCtxName
raise
def uninitializePlugin(mobject):
mplugin = mpx.MFnPlugin(mobject)
try:
mplugin.deregisterContextCommand(pluginCtxName)
except:
print "Failed to deregister context command: %s" % pluginCtxName
raise
I am looking for something more complex.