def jcStartBatch(batchArray, myAnimInfo, listType, batchList, sourceFile, logFile, logStyle, logPref): '''********************************************************* jcStartBatch Arguments: string $batchArray[] - the array that holds the items to be batched string $myAnimInfo[] - the array that holds the animation/pose info to be used as the source file string $listType - "batchListFiles" or "batchListFolders", what kind of items are in the batchList string $batchList - the name of the textScrollList to use as the batchList string $sourceFile - path to the source file to be applied to the batched items string $logFile - path to the log file string $logStyle - "batchErrorsOnly" or "batchVerbose", log only errors, or log everything string $logPref - "batchOverWriteLog" or "batchAppendLog", overwrite the old log or add to it Returns: none Notes: This will start the batching process based on the info in the batch tab **********************************************************''' allFiles = [] #jcStartBatch #local vars tempArray = [] myFolders = [] tempBuffer = [] tempFiles = [] allListItems = [] thisItem = "" thisDir = "" myFileType = "" myValueType = "" noTargets = [] #needed to pass to jcApplyAnim, it will always be empty thisFile = "" systemTime = "" systemDate = "" startTime = 0.0 elapsedTime = 0.0 i = 0 #progress variables batchCount=1 batchTotal=0 #make sure there are some files listed allListItems=cmds.textScrollList(batchList, query=1, allItems=1) if len(allListItems) == 0: pm.mel.error("No Files listed in the Batch List!\n") #error, no files if listType == "batchListFiles": allFiles=batchArray #error, no files #which type are we dealing with? #batch the files #batch the files #folders elif listType == "batchListFolders": #batch the folders #for each of the items in the batch list; check for recursion, get files #***REMOVE ME*** #$allListItems = `textScrollList -query -allItems $batchList`; #***REMOVE ME*** #loop through each item in the list for i in range(0,(len(allListItems))): thisItem=allListItems[i] #do each dir tempBuffer=thisItem.split("(") if tempBuffer[1] == "*)": thisDir=(batchArray[i] + "/") #do recursion #add slash to current path #get files from all folders below this one tempFiles=_listMyFiles(thisDir, allFiles, 1) #add to total file list _appendToArray(allFiles, tempFiles) #do recursion else: thisDir=(batchArray[i] + "/") #do each dir #add slash to current path #add files to total file list _appendToArray(allFiles, _listMyFiles(thisDir, allFiles, 0)) #do each dir #do each dir #batch the folders else: pm.mel.error("jcStartBatch can't handle the type: " + listType + "\n") #unknown type if sourceFile != "": if logFile != "": if logPref == "batchAppendLog": pass #unknown type #Setup the batch run #we have a source file #handle logging #start logging #setup echo to file #append #do nothing, as this is the default for the scriptEditorInfo function #append elif logPref == "batchOverWriteLog": logId=open(logFile,"w") #overwrite #clear out old log logId.write(("Animation Copy & Store Log File\n")) logId.close() if logStyle == "batchErrorsOnly": cmds.scriptEditorInfo(historyFilename=logFile, writeHistory=True) #overwrite #echo errors only #echo errors only elif logStyle == "batchVerbose": cmds.scriptEditorInfo(historyFilename=logFile, writeHistory=True) #echo all info systemTime=pm.internal.shellOutput("time /t", convertNewlines=False, stripTrailingNewline=False) #echo all info systemDate=pm.internal.shellOutput("date /t", convertNewlines=False, stripTrailingNewline=False) print "Batch Process Started on " + systemDate print systemTime + "\n" #start timer startTime=float(cmds.timerX()) #start logging else: print "No logging\n" #no logging myAnimInfo=str(jcLoadAnimFile("", sourceFile)) #no logging #Load the current file #grab the file type myFileType=str(jcGetFileType(myAnimInfo)) #grab the value type myValueType=str(jcGetValueType(myAnimInfo)) print "Start batching!\n" #Run the batch here: #do this to all files in total file list batchTotal=(len(allFiles)) for each in allFiles: print "\nFile: " + str(each) + "(" + str(batchCount) + " of " + str(batchTotal) + ")\n\n" #do each file #open target file if pm.catch(lambda: thisFile=str(cmds.file(each, open=1, force=1))): pm.mel.warning("Was unable to open: " + str(each) + " for batch process...\n") #oops #update the count and continue batchCount+=1 continue |