Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def createMapFiles():
- import maya.cmds as cmds
- import maya.mel as mel
- import time, os, subprocess
- allFileNodes = cmds.ls(type='file') # look for file nodes
- nonMapFiles = []
- 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
- fileExt = os.path.splitext(fileName)[1].lower()[1:] # get the extention
- if fileExt != 'map' : # test for anything but map files
- nonMapFiles.append(curFile)
- for curFile in nonMapFiles:
- curFileName = cmds.getAttr(curFile + '.fileTextureName') # get the filename
- newFileName = curFileName.replace(os.path.splitext(fileName)[1].lower()[1:],'map')
- bin_path = 'C:/Program Files/Autodesk/Maya2012/bin' # change this to the correct installation path of maya
- cmd = '%s/imf_copy -r -p %s %s' % (bin_path,curFileName, newFileName) # create the output command
- subprocess.call (cmd) # run the command
- if os.path.exists (newFileName) : #make sure the map file exists
- cmds.setAttr(curFile + '.fileTextureName' , newFileName, type='string') # set the attr to replace the file with the map
- else:
- print 'Error with map conversion for %s - %s' % (curFile, curFileName) # was it messed up? tell the user
- createMapFiles()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement