How do I execute Maya script without lauching Maya?

家住魔仙堡 提交于 2019-12-11 05:59:28

问题


For example, I want to launch a script that creates a poly cube, export it to .stl or .fbx from the command line.

I can do it in Python by using the Maya standalone but it cannot handle exporting to other formats than .ma apparently


回答1:


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)

Hope that was useful.



来源:https://stackoverflow.com/questions/27018520/how-do-i-execute-maya-script-without-lauching-maya

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!