import maya.cmds as cmds import os def sceneFileContents(filePath): ''' Creates a text file that lists all your nodes in order of node types. It puts it in your shot maya directory as a text file. ''' fileName = cmds.file(query = True, sn = True) nodes = cmds.ls(showType = True) size = len(nodes)/2 sceneContents = ["%s:\n\nThere are %i objects in this scene.\n" % (fileName,size)] #Build a Dictionary node_dictionary = {} for i in range(0, len(nodes), 2): node = nodes[i] nodeType = nodes[i+1] if not nodeType in node_dictionary: #If nodeType is not in dictionary, assign node as a list item node_dictionary[nodeType] = [node] else: #If nodeType is in dictionary, append node to the existing list node_dictionary[nodeType].append(node) for k in node_dictionary: sceneContents.append ('\nNode Type : %s (%s Nodes)\n' %(k,len(node_dictionary[k]))) for i, each in enumerate(node_dictionary[k]): sceneContents.append (' %d:%s\n' % (i, each)) sceneTxt = open(r'%ssceneContent.txt'%filePath, 'w') sceneTxt.writelines(sceneContents) sceneTxt.close() if __name__ == '__main__': sceneFileContents('/USERS/YourName/Desktop/')
Wednesday, September 5, 2012
sceneFileContents
I had the idea to write a python script that exported all your file contents neatly into a text file. I wrote some of it, but the important parts were written by old chocolate milk Dan Bradham. Just replace the directory with where you want the text file to be written.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment