-
-
Save fereria/d3febf270e43c61d31d3 to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
import maya.OpenMaya as om | |
import maya.OpenMayaMPx as omPx | |
#コマンドプラグインの場合は、 omPx.MPxCommandを継承(omPxはプロクシ?) | |
class HelloWorld(omPx.MPxCommand): | |
#Mayaでコマンドを実行する時のコマンド名はこれ | |
kPluginCmdName = "helloWorldCmd" | |
def __init__(self): | |
omPx.MPxCommand.__init__(self) | |
#Mainの実行 | |
#argsは MArgList で引数を受け取る | |
def doIt(self,args): | |
print "Hello World OpenMaya!!" | |
#コマンドのプロクシを、Maya側に引き渡し | |
def cmdCreator(): | |
return omPx.asMPxPtr(HelloWorld()) | |
#プラグインロード時に実行 | |
def initializePlugin(obj): | |
#plugin情報をSet | |
plugin = omPx.MFnPlugin( | |
obj, | |
"Remiria", | |
"1.0","1.0" | |
) | |
try: | |
#プラグインコマンドとクリエイタ?を初期化 | |
plugin.registerCommand(HelloWorld.kPluginCmdName,cmdCreator) | |
except: | |
#Error処理 | |
raise Exception( | |
"Error Command: %s" % HelloWorld.kPluginCmdName | |
) | |
#プラグインを解除時に読む | |
def uninitializePlugin(obj): | |
plugin = omPx.MFnPlugin(obj) | |
try: | |
plugin.deregisterCommand(HelloWorld.kPluginCmdName) | |
except: | |
raise Exception( | |
"Errror uninitializePlugin :%s"%HelloWorld.kPluginCmdName) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment