Hello Everyone,
I would like to create a stats file from various things that I am querying in Maya so basically as I run the script from mayabatch or script editor, I would like to export a txt with all the need data.
Thanks Martin
Hello Everyone,
I would like to create a stats file from various things that I am querying in Maya so basically as I run the script from mayabatch or script editor, I would like to export a txt with all the need data.
Thanks Martin
Add comment viewed 177 times Latest activity 11 months ago
Or you use PyMel and the usual Python stuff ... What I'm not sure about is if you actually can run PyMel from within a mayabatch ... Anyone?
You need to use fopen to open a new file to write, fprint to put stuff in the file, and fclose when you are done. Here are those commands in a procedure.
global proc string writeFile(string $filename,string $body) {
int $fileId = fopen($filename, "w" );
if (! $fileId) error("Couldn't open "+$filename+" for write");
fprint( $fileId, $body );
fclose( $fileId );
return $filename;
}
So, just gather all your stats into one big string, and call:
writeFile($fn,$stats);
Thanks Jan, I am really trying to stick with Python for now. However thanks for your input.
Hello Julian and thanks again for your help.
Here is the tool almost completed. This tool tells you how many polys and textures are in the scene and export that data to a txt file.
I am still having issues with regards to the exporting part. Can anyone help me out. I am still learning python. I really appreciate any assistance.
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 s