Python 官方文档:入门教程 => 点击学习
1. python的安装 在Eclipse中安装pydev环境,pydev更新地址为: Http://pydev.org/updates 2. 配置Python环境: 打开Eclipse菜单Window/Preferences,在PyD
1. python的安装
在Eclipse中安装pydev环境,pydev更新地址为: Http://pydev.org/updates
2. 配置Python环境:
打开Eclipse菜单Window/Preferences,在PyDev中配置Python Interpreter的设置如下:
注意要添加devkit\other\pymel\extras\completion\py目录。这样才有提示。
添加python代码:
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)
这个例子是官方的 Your First Maya Python Plug-in
还有更多例子,可以参考maya目录devkit下
参考文章:
1. Debugging Python in Maya with Eclipse/Pydev : http://around-the-corner.typepad.com/adn/2012/10/debugging-python-in-maya-with-eclipsepydev.html
2. Using Eclipse with Maya: A Quick Reference: http://techartninja.com/using-eclipse-with-maya-a-quick-reference/
3. Remote Maya Python Debugging in Eclipse: http://www.jason-parks.com/artoftech/?p=41
4. [pydev.org] Remote Debugger: http://pydev.org/manual_adv_remote_debugger.html
5. Setting Up PyMEL Autocompletion in Eclipse: http://download.autodesk.com/global/docs/maya2012/ja_jp/PyMel/eclipse.html
6. How to Setup PyMEL Autocompletion in Eclipse: https://pymel.Googlecode.com/svn/sphinx-docs/pymel_eclipse.html
--结束END--
本文标题: 用python编写maya插件
本文链接: https://lsjlt.com/news/192751.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0