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)
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.
For the moment I use this to export the camera as 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.
Any idea how I can specify to write in a text file with the .nk
extention ?
Thank you.
For batch conversion use a syntax like this to accomplish fbx
export:
import maya.mel as mel
mel.eval('FBXExport -f "/Users/swift/Desktop/fileName";')
You'll get fileName.fbx
file on your Desktop.
...or simply write what you want into .nk
file...
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.
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. And you'll get .nk
ASCII file.