Create a gist now

Instantly share code, notes, and snippets.

@fereria /helloWorld.py Secret
Created Feb 13, 2014

What would you like to do?
# -*- 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