/* alien, she wrote 1.0 ******what does this script do? this script check for the missing file(s) in a given sequence of images. ******what do I have to do to use it? copy this file to your script directory, then map "alienSheWrote()" to a shortcut or a shelf button ******how can I use it? do the shortcut or click the shelf button,and check...awesome!!! ^_^ ******limitations ...no limitations..at this moment! ^_^ ******credits Nicola Danese --> n.danese@ubik.it */ global proc checkSequence() { //get the vars string $fileName = `textFieldGrp -q -tx imageName`; string $padding = `textFieldGrp -q -tx padding`; string $extension = `textFieldGrp -q -tx extension`; string $range = `textFieldGrp -q -tx range`; int $checkSize = `checkBox -q -v checkSize`; //check fot empty string if ($range == "") { error "specify the render's range"; return; } //get the padding lenght int $paddingSize = size($padding); string $rangeSplitted[] = stringToStringArray ($range , "-"); int $sequenceStart = $rangeSplitted[0]; int $sequenceEnd = $rangeSplitted[1]; int $i,$emptyLine; string $stepStart = ""; string $stepEnd = ""; string $outputText = ""; string $outputSmedge = ""; string $smedgeLine = ""; int $singleFile; int $expected; int $missing = 0; int $checkForSize; int $sizeCheck = 2000; $expected = $sequenceEnd-$sequenceStart + 1; print ("\n\n*********************\n"); print ("List of missing files\n"); print ("*********************\n\n"); //progress bar global string $gMainProgressBar; // This is defined on maya startup float $frameTotali = $sequenceEnd - $sequenceStart; progressBar -edit -beginProgress -isInterruptable false -status ("PROGRESS: 0% ESTIMATED TIME REMAINING: please wait...") -maxValue $frameTotali $gMainProgressBar; float $actualPercent = 1; int $tempoRim = 0; int $actualCalc = 0; int $hStart,$mStart,$sStart,$hEnd,$mEnd,$sEnd; //start time string $bufferStart[]; string $dosTimeStart = `system time`; int $numTokens = `tokenize $dosTimeStart " " $bufferStart`; string $oraStart = `substring $bufferStart[2] 1 8`; string $oraStartStringArray[]; int $numTokens = `tokenize $oraStart "." $oraStartStringArray`; $hStart = $oraStartStringArray[0]; $mStart = $oraStartStringArray[1]; $sStart = $oraStartStringArray[2]; int $startSec = ($hStart * 3600) + ($mStart * 60) + $sStart; //get the directory string $directory = dirname( $fileName ); string $dirList = `system("dir /a-d /-c " + $directory + " > c:\\temp\\dirOutput.txt")`; $fileId=`fopen "c:\\temp\\dirOutput.txt" "r"`; string $bufferEnd[]; string $dosTimeEnd; string $oraEnd; string $oraEndStringArray[]; for ($i= $sequenceStart; $i<= $sequenceEnd; $i++) { //progress bar int $actualPerc = floor((($i-$sequenceStart)/($frameTotali))*100); if (($actualPerc%5 == 0) && ($actualCalc != $actualPerc)) { $dosTimeEnd = `system time`; $numTokens = `tokenize $dosTimeEnd " " $bufferEnd`; $oraEnd = `substring $bufferEnd[2] 1 8`; //print ($oraEnd + "\n"); $numTokens = `tokenize $oraEnd "." $oraEndStringArray`; $hEnd = $oraEndStringArray[0]; $mEnd = $oraEndStringArray[1]; $sEnd = $oraEndStringArray[2]; int $endSec = ($hEnd * 3600) + ($mEnd * 60) + $sEnd; int $diff = $endSec - $startSec; if ($actualPerc > 0) { $tempoRim = ($diff * (100 - $actualPerc)) / $actualPerc; } $actualCalc = $actualPerc; } progressBar -edit -step 1 -status ("PROGRESS: " + $actualPerc + "% ESTIMATED TIME REMAINING: "+ $tempoRim +" s") $gMainProgressBar; //put the index in the correct padding string $index = $i; while(size($index)<$paddingSize) { $index = "0" + $index; } //start the check sequence string $fileNameToCheck = $fileName + "." + $index + "." + $extension; $baseFileName = basename( $fileNameToCheck, "" ); //************************************************************ int $checkFileSize = 1; if ($checkSize) { //check the size of the files string $nextData = `fgetword $fileId`; string $previousData; while ( size($nextData) > 0 ) { $nextData = `fgetword $fileId`; if ($nextData == $baseFileName) { //print ($nextData + " --> " + $previousData +"\n"); int $fileSize = $previousData; //operatore ternario $checkFileSize = $fileSize>$sizeCheck ? 1 : 0; } $previousData = $nextData; } frewind $fileId; } //if the file exists if((`filetest -s $fileNameToCheck`) && ($checkFileSize)) { if ($outputText != "") { if ($singleFile) { $singleFile = 0; } print ($outputText + "\n"); $smedgeLine += ($outputSmedge + ","); $stepStart = $stepEnd = $outputText = ""; } } //if the file doesn't exists else { $missing++; if ($stepStart=="") { $stepStart = $i; $singleFile = 1; $outputText = ($stepStart); $outputSmedge = ($stepStart); } else { $stepEnd = $i; $singleFile = 0; $outputText = ($stepStart + " --> " + $stepEnd); $outputSmedge = ($stepStart + "-" + $stepEnd); } } } //if there's another output text... if ($outputText != "") { print ($outputText + "\n"); if ($stepEnd != "") { $outputSmedge = ($stepStart + "-" + $stepEnd); } else { $outputSmedge = ($stepStart); } $smedgeLine += ($outputSmedge + ","); } //************************************************************** //chiudo il file fclose $fileId; // cancello il file string $delFile = `system("del c:\\temp\\dirOutput.txt")`; //suono di fine check system "shell \"start /min sndrec32 /play /close C:\\WINDOWS\\Media\\Notify.wav\""; //cencello la progress bar progressBar -edit -endProgress $gMainProgressBar; int $perc = (100*$missing)/$expected; print ("\nExpected: " + $expected + " files\n"); print ("Missing: " + $missing + " files , " + $perc + "% \n"); if($missing>0) { print ("Smedge Line: " + `substring $smedgeLine 1 (size($smedgeLine) -1)` + "\n"); } } global proc int selectSceneFile( string $firstImage, string $fileType ) { string $imageName; int $i; textFieldButtonGrp -e -text $firstImage firstImage; string $tokens[]; $numTokens = `tokenize $firstImage "." $tokens`; int $counter = size($tokens) - 2; for ($i=0;$i < $counter;$i++) { $imageName += $tokens[$i]; } int $pad = size($tokens[size($tokens)-2]); string $padded = ""; for ($i = 0;$i<$pad;$i++) { $padded += "@"; } textFieldGrp -e -text $padded padding; textFieldGrp -e -text $tokens[size($tokens)-1] extension; //get the file name without extension string $basename = basename( $imageName, $tokens[size($tokens)-1] ); textFieldGrp -e -text $basename imageName; return 1; } //interface global proc alienSheWrote() { if (`window -ex alienSheWrote`) deleteUI alienSheWrote; //sound //system "shell \"start /min sndrec32 /play /close I:\\maya_plus\\scripts\\Murdershewrote.wav\""; window -title "Alien, she wrote 1.0" alienSheWrote; string $firstImage,$imageName,$padding,$extension; formLayout rcl1; separator -style "in" sep1; textFieldButtonGrp -label "Select Image" -tx $firstImage -buttonLabel " ... " -bc "fileBrowserDialog -m 0 -ft \"image\" -fc \"selectSceneFile\" -an \"Select\";" firstImage; textFieldGrp -label "Image Name" - text $imageName imageName; textFieldGrp -label "Padding" - text $padding padding; textFieldGrp -label "extension" - text $extension extension; separator -style "in" sep2; textFieldGrp -label "sequence range" range; separator -style "in" sep3; checkBox -label "1K check (slower)" -align "center" checkSize; separator -style "in" sep4; $submitButton= `button -h 25 -label "CHECK" -command "checkSequence()"`; $resetButton= `button -h 25 -label "RESET VALUES" -command "alienSheWrote()"`; $exitButton= `button -h 25 -label "EXIT" -command "evalDeferred \"deleteUI alienSheWrote\";"`; separator -style "in" sep5; formLayout -e -af sep1 "left" 0 -af sep1 "top" 5 -af sep1 "right" 0 -af firstImage "left" -40 -ac firstImage "top" 5 sep1 -af imageName "left" -40 -ac imageName "top" 2 firstImage -af padding "left" -40 -ac padding "top" 2 imageName -af extension "left" -40 -ac extension "top" 2 padding -af sep2 "left" 0 -ac sep2 "top" 5 extension -af sep2 "right" 0 -af range "left" -40 -ac range "top" 5 sep2 -af sep3 "left" 0 -ac sep3 "top" 3 range -af sep3 "right" 0 -af checkSize "left" 100 -ac checkSize "top" 5 sep3 -af sep4 "left" 0 -ac sep4 "top" 3 checkSize -af sep4 "right" 0 -af $submitButton "left" 100 -ac $submitButton "top" 5 sep4 -ac $resetButton "left" 30 $submitButton -ac $resetButton "top" 5 sep4 -ac $exitButton "left" 30 $resetButton -ac $exitButton "top" 5 sep4 -af sep5 "left" 0 -ac sep5 "top" 5 $exitButton -af sep5 "right" 0 rcl1; showWindow alienSheWrote; }