如何在不启动Maya的情况下执行Maya脚本?
问题描述:
例如,我要启动一个创建多边形多维数据集的脚本,然后将其从命令行导出到.stl或.fbx.
For example, I want to launch a script that creates a poly cube, export it to .stl or .fbx from the command line.
我可以使用Maya独立版在Python中完成此操作,但显然无法处理导出为.ma以外的其他格式
I can do it in Python by using the Maya standalone but it cannot handle exporting to other formats than .ma apparently
答
当然可以.这就是您要针对FBX精确执行的操作:
Why of course you can. Here's how you'd do exactly that (for FBX):
from os.path import join
from maya.standalone import initialize
import maya.cmds as cmds
import maya.mel as mel
initialize("python")
cmds.loadPlugin("fbxmaya")
my_cube = cmds.polyCube()
cmds.select(my_cube[0], r=True)
my_filename = "cube2.fbx"
my_folder = "C:/SomeFolder/scenes"
full_file_path = join(my_folder, my_filename).replace('\\', '/')
mel.eval('FBXExport -f "%s"' % full_file_path)
希望是有用的.