In an effort to have more transparency in what I do, I am going to open source a lot of the code I have written for VFX work. The work below represents a subset of things I am working on currently.
http://www.assembla.com/spaces/mayatools – Maya 2011 code
-
def vrayAddGamma():
-
import maya.cmds as cmds
-
import maya.mel as mel
-
import time, os
-
allFileNodes = cmds.ls(type=‘file’) # look for file nodes
-
nonFloatFiles = []
-
for curFile in allFileNodes:
-
-
cmds.setAttr (curFile + ‘.filterType’, 0) # turn off the damned filtering
-
fileName = cmds.getAttr(curFile + ‘.fileTextureName’) # get the filename
-
if fileName != ”: # test for stupid user
-
#print fileName
-
fileExt = os.path.splitext(fileName)[1].lower()[1:] # get the extention
-
#fileExt = fileExt.lower()[1:]
-
#print fileExt
-
if fileExt != ‘exr’ or fileExt != ‘.hdr’: # test for hdr and exr
-
nonFloatFiles.append(curFile)
-
mel.eval(‘vray addAttributesFromGroup ‘ + curFile + ‘ vray_file_gamma 1′) # add the proper vray stuff to the attribs
-
time.sleep(5) # have to sleep because maya is a pain in the asssssssssss!!!
-
allFileNodes = cmds.ls(type=‘file’) # look for file nodes
-
for curFile in nonFloatFiles:
-
if cmds.objExists(curFile + ‘.vrayFileGammaEnable’):
-
cmds.setAttr (curFile + ‘.vrayFileGammaEnable’, 1) # make sure the gamma correction is enabled
-
cmds.setAttr (curFile + ‘.vrayFileColorSpace’, 2) # set it to sRGB
-
else :
-
print ‘The attribute for VRay is not found in %s’ % curFile
-
-
vrayAddGamma()
