hey im trying to figure out how to create contexts in maya via the python api
this is what i got this thus far.
import maya.OpenMaya as om
import maya.OpenMayaMPx as mpx
import sys
kPluginCtxName = 'myContext'
kPluginCmdName = 'myContextCmd'
class context(mpx.MPxContext):
def __init__(self):
mpx.MPxCommand.__init__(self)
def doPress(self, event):
sys.stderr.write('It works I hope!!!!!')
class contextCommand(mpx.MPxContextCommand):
def __init__(self):
mpx.MPxContextCommand.__init__(self)
def makeObj(self):
return mpx.asMPxPtr(context())
@classmethod
def creator(cls):
return mpx.asMPxPtr(cls())
def initializePlugin(mobject):
mplugin = mpx.MFnPlugin(mobject, "Passerby", "1.0", "Any")
try:
mplugin.registerContextCommand(kPluginCtxName, contextCommand.creator)
except:
sys.stderr.write("Failed to register context command: %s
" % kPluginCtxName)
raise
# Uninitialize the script plug-in
def uninitializePlugin(mobject):
mplugin = mpx.MFnPlugin(mobject)
try:
mplugin.deregisterContextCommand(kPluginCtxName, kPluginCmdName)
except:
sys.stderr.write("Failed to deregister context command: %s
" % kPluginCtxName)
raise
the plugin loads without errors, but the problem is once i call maya.cmds.myContext() i get this error.
# Error: TypeError: file <string> line 2: Swig director type mismatch in output value of type 'MPxContext *' #