简体   繁体   English

批量转换Maya文件

[英]Batch convert Maya files

I'm actually working on a script to convert a very basic Maya .ma scene to Nuke .nk project using Maya batch mode (mayapy.exe) 我实际上是在使用Maya批处理模式(mayapy.exe)将非常基本的Maya .ma场景转换为Nuke .nk项目的脚本。

I have found how to select, search infos from camera but I don't know how to export them in a text file, as a text file with .nk extention works in Nuke. 我已经找到了如何从相机中选择搜索信息,但我不知道如何将其导出到文本文件中,因为具有.nk扩展名的文本文件在Nuke中有效。 For the moment I use this to export the camera as FBX : 目前,我使用它来将相机导出为FBX:

outputFilename = os.path.splitext(current)[0]+'.fbx'
    print "Output file: ", outputFilename

cmds.file(outputFilename, exportSelected=True, typ="FBX export", force=True, options="v=0;", es=1)

But that cant work for text file or .nk file as Maya doesn't have this option in export settings. 但这.nk用于文本文件或.nk文件,因为Maya在导出设置中没有此选项。 Any idea how I can specify to write in a text file with the .nk extention ? 我知道如何指定扩展.nk的文本文件吗?

Thank you. 谢谢。

For batch conversion use a syntax like this to accomplish fbx export: 对于批量转换,请使用如下语法来完成fbx导出:

import maya.mel as mel

mel.eval('FBXExport -f "/Users/swift/Desktop/fileName";')

You'll get fileName.fbx file on your Desktop. 您将在桌面上获得fileName.fbx文件。

...or simply write what you want into .nk file... ...或者只是将您想要的内容.nk文件中...

fileName = "/Users/swift/Desktop/fileName.nk"

# pass in 'r' for reading a file
# pass in 'r+' for reading and writing a file
# pass in 'w' for overwriting the file
# pass in 'a' for appending to the file

fileWrite = open(fileName,'w')

# write here a content of .nk file
fileWrite.write('Hello, NUKE! ...blah, blah, blah...') 
fileWrite.close()

You'll get fileName.nk file on your Desktop. 您将在桌面上获得fileName.nk文件。


For non-batch conversion use the code like this: 对于非批量转换,请使用如下代码:

from pymel.core import *

fileName = fileDialog2()
print fileName[0]
fileWrite = open(fileName[0],'w')

# write here a content of .nk file
fileWrite.write('Hello, NUKE') 
fileWrite.close()
print open(fileName[0],'r').read()

In opened dialog box just type fileName with .nk extension. 在打开的对话框中,键入扩展名为.nk fileName And you'll get .nk ASCII file. 然后您将获得.nk ASCII文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM