Created
March 7, 2015 12:17
-
-
Save ourway/b0041657e7fd708203c7 to your computer and use it in GitHub Desktop.
Maya scripted command plug-in
This file contains 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 sys | |
import maya.OpenMaya as OpenMaya | |
import maya.OpenMayaMPx as OpenMayaMPx | |
kPluginCmdName = "spHelloWorld" | |
# Command | |
class scriptedCommand(OpenMayaMPx.MPxCommand): | |
def __init__(self): | |
OpenMayaMPx.MPxCommand.__init__(self) | |
# Invoked when the command is run. | |
def doIt(self,argList): | |
print "Hello World!" | |
# Creator | |
def cmdCreator(): | |
return OpenMayaMPx.asMPxPtr( scriptedCommand() ) | |
# Initialize the script plug-in | |
def initializePlugin(mobject): | |
mplugin = OpenMayaMPx.MFnPlugin(mobject) | |
try: | |
mplugin.registerCommand( kPluginCmdName, cmdCreator ) | |
except: | |
sys.stderr.write( "Failed to register command: %s\n" % kPluginCmdName ) | |
raise | |
# Uninitialize the script plug-in | |
def uninitializePlugin(mobject): | |
mplugin = OpenMayaMPx.MFnPlugin(mobject) | |
try: | |
mplugin.deregisterCommand( kPluginCmdName ) | |
except: | |
sys.stderr.write( "Failed to unregister command: %s\n" % kPluginCmdName ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment