Maya设置
-
下载maya开发者扩展内容,这里注意你的maya版本;地址:https://www.autodesk.com/developer-network/platform-technologies/maya
-
文件解压后将devkitBase下的文件覆盖放到maya安装目录下
-
打开maya脚本编辑器,运行一下代码设置链接端口
import maya.cmds as cmds; if not cmds.commandPort(':7001', q = True ): cmds.commandPort(name=":7001", sourceType="mel", echoOutput=True) cmds.warning('Mel port is open...') else: cmds.commandPort(name = ':7001', cl = 1) cmds.warning('Mel port is close...') if not cmds.commandPort(':7002', q = True): cmds.commandPort(name=":7002", sourceType="python", echoOutput=True) cmds.warning('Python port is open...') else: cmds.commandPort(name = ':7002', cl = 1) cmds.warning('Python port is close...')
- 或者使用mel命令
commandPort -name "localhost:7001" -sourceType "mel" -echoOutput; commandPort -name "localhost:7002" -sourceType "python" -echoOutput;
VS Code 配置
-
插件设置
-
安装python插件
-
安装MayaPort插件
vs code 工作区设置(用户设置)
-
打开设置界面
-
这里根据自己的需求选择“用户设置”或“工作区设置”
-
覆盖用户设置,输入以下代码,路径根据自己maya版本及安装位置更改
{ "python.autoComplete.extraPaths": [ "C:/Program Files/Autodesk/Maya2018/devkit/other/pymel/extras/completion/py", "C:/Program Files/Autodesk/Maya2018/bin", "C:/Program Files/Autodesk/Maya2018/bin/python27.zip", "C:/Program Files/Autodesk/Maya2018/Python", "C:/Program Files/Autodesk/Maya2018/Python/DLLs", // "C:/Program Files/Autodesk/Maya2018/Python/Lib/site-packages", "C://Users//52316//Anaconda2//pkgs//python-2.7.15-he216670_0//Lib", ], "python.pythonPath": "C:/Program Files/Autodesk/Maya2018/bin/mayapy.exe", }
- mac版本
{ "python.autoComplete.extraPaths": [ "/Applications/Autodesk/Maya2017/devkit/other/pymel/extras/completion/py", ], "python.pythonPath":"/Applications/Autodesk/Maya2017/Maya.app/Contents/bin/mayapy", }
-
重启vs code,输入代码就会有智能提示了
-
链接到maya:
-
按下F1,执行mayaPort命令,创建链接
- 按下 Shift +Alt + P发送到Maya执行python命令
- 按下 Shift + Alt + M 发送到Maya执行Mell命令