Well that sounds very interesting.
On the other hand, the poster didn't specify why they wanted it in the file.
I need to do something just like it for adding metadata to the end of a .ma file.
(It's used in conjunction with a snapshot of the scene at save time to produce a superfast Mac OSX "Quicklook" view of a scene file)
There is plenty of data polled by this, if you wish more then by all means add it, and the same goes for subraction.
Referenced files/locations, texture files/locations, renderable cameras, image format, list goes on.
btw, In 8.5 SP1 I tried using mayabatch and it says not found, I also tried it as mayaBatch no dice.
CODE
//This script is meant to poll scene data from a Maya scene file and store it as an ASCII file
//to help with determining Revision changes, render settings, shot length, etc.
//I can't help but lose my place once I've animated a scene long enough!
global proc sceneDataExporter()
{
if ( window -q -ex sceneInfoWindow
) deleteUI sceneInfoWindow;
string $myWin = window -height 40 -rtf 1 -title "Scene Info Exporter" sceneInfoWindow
;
columnLayout;
textFieldButtonGrp -width 500 -height 30
-label "Revision Notes:" -buttonLabel "Export Scene Info"
-buttonCommand "saveInfo()" textButton;
text -label "(If empty blank returns 'Incremental Save')" -width 500 -height 15 -align "center" adviseText;
showWindow $myWin;
}
global proc saveInfo()
{
// If you are on a Mac, and have a problem where the file's name includes the folder name it was being saved to
// and is instead in the parent's folder, ie; Saving to /Projects/scenes/output.pot turns out to be /Projects/scenesoutput.pot
// This is a bug in Maya (I believe) and is solved in later versions.
// Worakaround: When saving the file: "output.txt" place "/" in front of it: "/output.txt" and it works perfectly!
string $fileName = fileDialog -dm "*.txt" -m 1
;
int $fileID = fopen $fileName "w"
;
string $sceneName = file -q -sn -shn
;
fprint $fileID "\n";
fprint $fileID ("This_is_an_info_file_for_Maya_scene:" + "\n");
fprint $fileID ($sceneName + "\n");
fprint $fileID (file -q -sn
+ "\n");
fprint $fileID "\n";
fprint $fileID ("Scene_Save_Date:" + "\n");
fprint $fileID (about -currentTime
+ " " + about -currentDate
+ "\n");
fprint $fileID "\n";
fprint $fileID ("Operating_System_Created_On:" + "\n");
fprint $fileID (about -osv
+ "\n");
fprint $fileID "\n";
fprint $fileID ("Maya_Version:" + "\n");
fprint $fileID (about -v
+ "\n");
// This includes the textField entry, or if it is blank "Incremental Save" is inserted as default.
fprint $fileID "\n";
fprint $fileID ("User_Version_Notes:" + "\n");
if (size(textFieldButtonGrp -q -text textButton
) == 0 )
{
fprint $fileID ("Incremental Save" + "\n");
}
else
{
fprint $fileID (textFieldButtonGrp -q -text textButton
+ "\n");
}
// Queries referenced files, then displays them and their paths:
string $sceneReferences[] = ls -type reference
;
if ( size($sceneReferences) >= 1)
{
fprint $fileID "\n";
fprint $fileID ("Scene_References:" + "\n");
}
for ( $i=0; $i < (size($sceneReferences)); $i++ )
{
string $sceneRefQuery = referenceQuery -f $sceneReferences[($i)]
;
fprint $fileID (basename( $sceneRefQuery, "" ) + "\n");
fprint $fileID ($sceneRefQuery + "\n");
}
// This block gathers textures if they exist and prints files and their paths to all textures that HAVE files:
string $textures[] = ls -textures
;
int $numTexts = size($textures)
;
if ($numTexts >= 1)
{
fprint $fileID "\n";
fprint $fileID ("Textures_in_Scene:" + "\n");
}
for ($i=0; $i < $numTexts; $i++)
{
if ( attributeQuery -ex -node $textures[($i)] "fileTextureName"
== 1)
{
string $locTextures = getAttr ($textures[($i)] + ".fileTextureName")
;
fprint $fileID (basename ($locTextures, "") + "\n");
fprint $fileID ($locTextures + "\n");
}
}
// This block is for Timeline Range:
fprint $fileID ("\n" + "Timeline_Start:" + "\n");
fprint $fileID (playbackOptions -q -ast
+ "\n");
fprint $fileID ("\n" + "Timeline_End:" + "\n");
fprint $fileID (playbackOptions -q -aet
+ "\n");
fprint $fileID ("\n" + "Frames_in_Timeline_Range:" + "\n");
fprint $fileID (playbackOptions -q -aet
- playbackOptions -q -ast
+ "\n");
// This block is for Render Frame Range:
fprint $fileID ("\n" + "Render_Range_Start:" + "\n");
fprint $fileID (getAttr "defaultRenderGlobals.startFrame"
+ "\n");
fprint $fileID ("\n" + "Render_Range_End:" + "\n");
fprint $fileID (getAttr "defaultRenderGlobals.endFrame"
+ "\n");
fprint $fileID ("\n" + "Render_Frame_Range:" + "\n");
fprint $fileID (getAttr "defaultRenderGlobals.endFrame"
- getAttr "defaultRenderGlobals.startFrame"
+ "\n");
// This block is for Renderer Attributes:
fprint $fileID ("\n" + "Current_Renderer:" + "\n");
fprint $fileID (getAttr "defaultRenderGlobals.currentRenderer"
+ "\n");
fprint $fileID ("\n" + "Render_Resolution:" + "\n");
fprint $fileID ( getAttr "defaultResolution.width"
+ " x " +
getAttr "defaultResolution.height"
+
" " + getAttr "defaultResolution.dotsPerInch"
+ " dpi" + "\n");
// This block determines what the Default size units for images:
int $defaultSizeUnit = getAttr "defaultResolution.imageSizeUnits"
;
fprint $fileID ("\n" + "Image_Size_Units:" + "\n");
if ( $defaultSizeUnit == 0)
{
fprint $fileID ("pixels" + "\n");
}
else if ( $defaultSizeUnit == 1)
{
fprint $fileID ("inches" + "\n");
}
else if ( $defaultSizeUnit == 2)
{
fprint $fileID ("cm" + "\n");
}
else if ( $defaultSizeUnit == 3)
{
fprint $fileID ("mm" + "\n");
}
else if ( $defaultSizeUnit == 4)
{
fprint $fileID ("points" + "\n");
}
else if ( $defaultSizeUnit == 5)
{
fprint $fileID ("picas" + "\n");
}
int $pixelDensityUnits = getAttr "defaultResolution.imageSizeUnits"
;
fprint $fileID ("\n" + "Pixel_Density_Units:" + "\n");
if ( $pixelDensityUnits == 0)
{
fprint $fileID ("pixels|inch" + "\n");
}
else if ( $pixelDensityUnits == 1 )
{
fprint $fileID ("pixels|cm" + "\n");
}
fprint $fileID ("\n" + "Frame_Padding:" + "\n");
fprint $fileID (getAttr "defaultRenderGlobals.extensionPadding"
+ "\n");
// Getting the renderable camera list is tricky. In Render Globals Maya does this operation
// to find renderable cameras, then sets one you select to renderable and turns the others "off".
// The problem? Render Globals will NOT turn off cameras users MANUALLY turned on the "renderable" attribute.
// To combat the problem this script identifies ALL renderable cameras.
// (For readability the word "Shape" is removed from ALL camera returns)
fprint $fileID ("\n" + "Renderable_Camera(s):" + "\n");
string $cam[] =ls -type "camera"
;
for ($i=0; $i < size($cam); $i++)
{
float $renderable = getAttr ($cam[($i)] +".renderable")
;
string $garbage = "Shape";
if ($renderable == 1)
{
fprint $fileID (substitute $garbage $cam[($i)] ""
+ "\n");
}
}
// This block goes through the lengthy process of discovering the fileType and attaching it to the end
// of the fileName. It will return "Unknown if the format is one not in this list. (a format older/newer than of this writing)
fprint $fileID ("\n" + "Image_Filename:" + "\n");
string $imageFilename = getAttr "defaultRenderGlobals.imageFilePrefix"
;
if ( $imageFilename == "")
{
string $imageFilename = "Name not Set";
fprint $fileID $imageFilename;
}
string $imageFileFormat = getAttr "defaultRenderGlobals.imageFormat"
;
if ( $imageFileFormat == 0)
{
fprint $fileID ($imageFilename + ".gif GIF" + "\n");
}
else if ( $imageFileFormat == 1)
{
fprint $fileID ($imageFilename + ".pic Softimage" + "\n");
}
else if ( $imageFileFormat == 2)
{
fprint $fileID ($imageFilename + ".rla RLA" + "\n");
}
else if ( $imageFileFormat == 3)
{
fprint $fileID ($imageFilename + ".tif Tiff" + "\n");
}
else if ( $imageFileFormat == 4)
{
fprint $fileID ($imageFilename + ".tif Tiff16" + "\n");
}
else if ( $imageFileFormat == 5)
{
fprint $fileID ($imageFilename + ".sgi SGI" + "\n");
}
else if ( $imageFileFormat == 6)
{
fprint $fileID ($imageFilename + ".als Alias Pix" + "\n");
}
else if ( $imageFileFormat == 7)
{
fprint $fileID ($imageFilename + ".iff Maya IFF" + "\n");
}
else if ( $imageFileFormat == 8)
{
fprint $fileID ($imageFilename + ".jpg JPEG" + "\n");
}
else if ( $imageFileFormat == 9)
{
fprint $fileID ($imageFilename + ".eps EPS" + "\n");
}
else if ( $imageFileFormat == 10)
{
fprint $fileID ($imageFilename + ".iff Maya16 IFF" + "\n");
}
else if ( $imageFileFormat == 11)
{
fprint $fileID ($imageFilename + ".cin Cineon" + "\n");
}
else if ( $imageFileFormat == 12)
{
fprint $fileID ($imageFilename + ".yuv Quantel" + "\n");
}
else if ( $imageFileFormat == 13)
{
fprint $fileID ($imageFilename + ".sgi SGI16" + "\n");
}
else if ( $imageFileFormat == 19)
{
fprint $fileID ($imageFilename + ".tga Targa" + "\n");
}
else if ( $imageFileFormat == 20)
{
fprint $fileID ($imageFilename + ".bmp Windows Bitmap" + "\n");
}
else if ( $imageFileFormat == 22)
{
fprint $fileID ($imageFilename + ".mov Quicktime Movie" + "\n");
}
else if ( $imageFileFormat == 30)
{
fprint $fileID ($imageFilename + ".pntg MacPaint" + "\n");
}
else if ( $imageFileFormat == 31)
{
fprint $fileID ($imageFilename + ".psd PSD" + "\n");
}
else if ( $imageFileFormat == 32)
{
fprint $fileID ($imageFilename + ".png PNG" + "\n");
}
else if ( $imageFileFormat == 33)
{
fprint $fileID ($imageFilename + ".pict QuickDraw" + "\n");
}
else if ( $imageFileFormat == 34)
{
fprint $fileID ($imageFilename + ".qtif Quicktime Image" + "\n");
}
else if ( $imageFileFormat == 35)
{
fprint $fileID ($imageFilename + ".dds DDS" + "\n");
}
else if ( $imageFileFormat == 36)
{
fprint $fileID ($imageFilename + ".psd PSD Layered" + "\n");
}
else if ( $imageFileFormat == 50)
{
fprint $fileID ($imageFilename + ".xpm (XPM) OR .tim (Playstation)" + "\n");
}
else
{
fprint $fileID ($imageFilename + " Unknown Extension" + "\n");
}
fclose $fileID;
}