Created
December 10, 2019 19:46
-
-
Save santosh/3fb8e7d9d0ba234359046b6e6547311f to your computer and use it in GitHub Desktop.
Custom command inside maya. Similarly custom nodes can be created. Part of ADN.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.OpenMayaMPx as ommpx | |
import sys | |
class Sample(ommpx.MPxCommand): | |
kPluginCmdName = "foo" | |
def __init__(self): | |
ommpx.MPxCommand.__init__(self) | |
@classmethod | |
def cmdCreator(cls): | |
return ommpx.asMPxPtr(cls()) | |
def doIt(self, argList): | |
print("Hello World") | |
def initializePlugin(mobject): | |
mplugin = ommpx.MFnPlugin(mobject) | |
try: | |
mplugin.registerCommand(Sample.kPluginCmdName, Sample.cmdCreator) | |
except: | |
sys.stderr.write("Failed to register command: {}".format(Sample.kPluginCmdName)) | |
raise | |
def uninitializePlugin(mobject): | |
mplugin = ommpx.MFnPlugin(mobject) | |
try: | |
mplugin.deregisterCommand(Sample.kPluginCmdName) | |
except: | |
sys.stderr.write( | |
"Failed to unregister command: {}".format(Sample.kPluginCmdName) | |
) | |
raise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment