Here is example of mine!
import maya.cmds as cmds
def getStats():
#List all the geometry in the scene.
mySel =
cmds.ls( geometry=True )
#List the path of all the textures in the scene.
texturesPath =
cmds.ls(type = "file")
#List the total amount of textures in the scene.
numTextures = len(
cmds.ls(type = "file"))
#Gives the total polyCount.
totalPolyCount = cmds.polyEvaluate(mySel, face = True)
#Goes though each texture and returns their fullpath.
#for texture in texturesPath:
#print(cmds.getAttr (texture + ".fileTextureName"))
#print out the total amount of polys in the scene.
#print('The scene has a total of: ' + str(totalPolyCount) + ' ' + 'polys' )
#return a dictionary of the tottal amount of textures and polys in the scene.
return {
'totalPolys' : totalPolyCount,
'totalTextures' : numTextures,
}
#Ask the user for the location fo the maya scene.
def AskUserForFilename():
filename = cmds.fileDialog2(fileMode=1, caption="Import scene")
cmds.file( filename[0], i=True )
#Get polycount function.
def getPolyCount(polys):
totalPolyCount = polys
#Get texturecount funcion.
def getNumTextures(textures):
numTextures = textures
#Open a text file, write on it and close it.
def saveStatsToFile(filename, stats):
totalPolyCount = stats
fileHandle = open (filename, 'w')
fileHandle.write (filename )
fileHandle.close()
return filename, stats
#Get all the stats and save them in a text file.
def GetSceneStatsAndSaveToFile(stats):
AskUserForFilename()
totalPolyCount = stats
return {
'CollectedStats': getStats(),
'TextFileCreated': saveStatsToFile('stats.txt', str(stats),)
}
#Final Everything.
GetSceneStatsAndSaveToFile(3)
--
Martin La Land Romero
www.martinromerovfx.comhttp://martinromerovfx.blogspot.com/
martin...@gmail.com(415)261-2172