Prev
Next

Day After Tomorrow

The Last Airbender

Iron Man 2

Final Composite

Iron Man 2

Original Plate

SAAB

Audi

Priest

Priest

Priest

Vanilla Sky

Archetype

Day After Tomorrow

Mezzo

Nine Inch Nails

Ford

Code

Code

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

  1. def vrayAddGamma():
  2.         import maya.cmds as cmds       
  3.         import maya.mel as mel
  4.         import time, os
  5.         allFileNodes = cmds.ls(type=‘file’) # look for file nodes
  6.         nonFloatFiles = []
  7.         for curFile in allFileNodes:
  8.                
  9.                 cmds.setAttr (curFile + ‘.filterType’, 0) # turn off the damned filtering
  10.                 fileName = cmds.getAttr(curFile + ‘.fileTextureName’) # get the filename
  11.                 if fileName != : # test for stupid user
  12.                         #print fileName
  13.                         fileExt = os.path.splitext(fileName)[1].lower()[1:] # get the extention
  14.                         #fileExt = fileExt.lower()[1:]
  15.                         #print fileExt
  16.                         if fileExt != ‘exr’ or fileExt != ‘.hdr’: # test for hdr and exr
  17.                                 nonFloatFiles.append(curFile)
  18.                                 mel.eval(‘vray addAttributesFromGroup ‘ + curFile + ‘ vray_file_gamma 1′) # add the proper vray stuff to the attribs
  19.         time.sleep(5) # have to sleep because maya is a pain in the asssssssssss!!!
  20.         allFileNodes = cmds.ls(type=‘file’) # look for file nodes
  21.         for curFile in nonFloatFiles:
  22.                 if cmds.objExists(curFile + ‘.vrayFileGammaEnable’):
  23.                         cmds.setAttr (curFile + ‘.vrayFileGammaEnable’, 1) # make sure the gamma correction is enabled
  24.                         cmds.setAttr (curFile + ‘.vrayFileColorSpace’, 2) # set it to sRGB
  25.                 else :
  26.                         print ‘The attribute for VRay is not found in %s’ % curFile            
  27.  
  28. vrayAddGamma()
Stop SOPA