Gnn*_*Gnn 4 python ascii maya mel
.ma我正在尝试在 Python 脚本末尾打开一个 Maya 场景,
路径看起来像这样:G:\ProjectPath\Scene.ma。
但我知道的唯一命令是 MEL 命令:
file -f -options "v=0; p=17; f=0" -ignoreVersion -typ "mayaAscii" -o
"G:/ProjectPath/Scene.ma";
addRecentFile("G:/ProjectPath/Scene.ma", "mayaAscii");
Run Code Online (Sandbox Code Playgroud)
有人知道如何用 Python 实现这一点吗?
您可以通过以下方式通过 Python 快速完成此操作:
import maya.cmds as cmds
# Windows path version
cmds.file('G:/ProjectPath/Scene.ma', o=True)
# Mac path version
cmds.file('/Users/mac/Desktop/Scene.ma', o=True)
Run Code Online (Sandbox Code Playgroud)
或者,如果您收到如下消息,请尝试此版本# Error: Unsaved changes:
file_path = 'G:/ProjectPath/Scene.ma'
cmds.file(new=True, force=True)
cmds.file(file_path, open=True)
Run Code Online (Sandbox Code Playgroud)