/***************************************** Script by Jos Balcaen you can contact me @ josbalcaen.com *****************************************/ global myRoll global roll_GlobalSettings try( DestroyDialog) myRoll catch() ( struct strMaxFile ( bPrivateOverride = false, bTimeOutput = false, TimeOutputType = 1, RangeFrom = 0, RangeTo = 1, bOutputSize = false, OutputWidth = 0, OutputHeight = 0, bSave = false, SaveFolder = "", SaveType = "" )--end struct strMaxFile local ArrMaxFiles = #() rollout myRoll "Render Multiple Max Files with BatchCam support" ( local number_of_files = 0 local ListOfMaxFiles = #() local savePath = "" local numberselected = 0 button btnBrowseFile "Browse for files" across:2 width:500 align:#left button btnBrowseFolder "Folder" width:60 align:#left offset:[220,0] multilistbox mlbMaxFiles label lbNumberOfFiles " No files selected" across:3 align:#left button btnRemoveSelected "Remove" align:#right width:100 offset:[85,0] tooltip:"Remove selected files from list." button btnRemoveAll "Remove all" align:#right width:100 tooltip:"Remove all files from the list." SubRollout subroll_OverwriteSettings "Overwrite Settings" height:65 button btnRender "Render all files" width:490 height:30 align:#left across:2 button btnRender2 "BatchCamera" width:80 height:30 align:#right enabled:(doesfileexist ((getdir #usermacros) + @"\Sergo Pogosyan-BatchCameraRender.mcr")) progressbar prgProgressFiles value:100 color:green height:7 --progressbar prgProgressFrame value:100 color:green height:7 label lblInfo "Select Files To Render..." align:#left across:2 label jos "Made by Jos Balcaen" align:#right on btnBrowseFile pressed do ( theDialog = dotNetObject "System.Windows.Forms.OpenFileDialog" --create a OpenFileDialog theDialog.title = "PLEASE Select One Or More Files" --set the title theDialog.Multiselect = true --allow multiple files to be selected theDialog.Filter = "MAX Files (*.max)|*.max"--|"All Files (*.*)|*.*" --specify the filter theDialog.FilterIndex = 1 --set the filter drop-down list to All Files result = theDialog.showDialog() --display the dialog, get result into variable result.ToString() --when closed, convert the result to string --result.Equals result.OK --returns TRUE if OK was pressed, FALSE otherwise result.Equals result.Cancel --returns TRUE if Cancel was pressed, FALSE otherwise if result.Equals result.OK == true do ( files = theDialog.fileNames --the selected filenames will be returned as an array for file in files do ( appendIfUnique ListOfMaxFiles file ) mlbMaxFiles.items = ListOfMaxFiles number_of_files = mlbMaxFiles.items.count lbNumberOfFiles.text = "All files" /* index = ArrMaxFiles.count + 1 for item in theDialog.fileNames do ( ArrMaxFiles[index] = strMaxFile() ) */ ) ) -- end on btnBrowseFile pressed on btnBrowseFolder pressed do ( folder = getSavePath "Save to:" initialDir:"" as string--getOpenFileName() --(getDir #maxroot) files = getFiles(folder + "\*.max") -- get max files in folder for file in files do ( appendIfUnique ListOfMaxFiles file ) --join ListOfMaxFiles files mlbMaxFiles.items = ListOfMaxFiles number_of_files = mlbMaxFiles.items.count lbNumberOfFiles.text = "All files" )--end on btnBrowseFolder pressed on mlbMaxFiles selected arg do ( numberselected = 0 bitArr = mlbMaxFiles.selection for i = 1 to bitArr.count do (if bitArr[i] == true do numberselected+=1) lbNumberOfFiles.text = numberselected as string + " files selected" )--end on mlbMaxFiles selected arg on mlbMaxFiles doubleClicked index do ( itemArr = mlbMaxFiles.items ListOfMaxFiles = deleteItem itemArr index mlbMaxFiles.items = ListOfMaxFiles )--end on mlbMaxFiles doubleClicked index on btnRemoveAll pressed do ( ListOfMaxFiles = #() mlbMaxFiles.items = ListOfMaxFiles ) on btnRemoveSelected pressed do ( itemArr = mlbMaxFiles.items sel = mlbMaxFiles.selection print sel itemsToDel = #() for i in sel do ( append itemsToDel itemArr[i] ) print itemsToDel for toDel in itemsToDel do ( check = findItem itemArr toDel if check != 0 do (deleteItem itemArr check) ) ListOfMaxFiles = itemArr mlbMaxFiles.items = ListOfMaxFiles mlbMaxFiles.selection = #() lbNumberOfFiles.text = "selected files deleted" ) fn regularRenderFn = ( --max file is geladen --file instellen waar nodig sFrame = "" sCamera = "" sFramerange = "" sFromframe = "" sToframe = "" sOutputwidth = "" sOutputHeight = "" sOutputfile = "" sVfb = "" if roll_GlobalSettings.chbTimeOutput.checked == true then ( case roll_GlobalSettings.rdbTimeOutput.state of ( 1:(sFrame = "frame:#current ") -- single frame 2:(sFramerange = "framerange:#active ") -- active time segment 3:(sFromframe = "fromframe:" + roll_GlobalSettings.spnFrom.value as string + " " -- user specified range sToframe = "toframe:" + roll_GlobalSettings.spnTo.value as string + " ") ) )--end if else -- get timeoutput from file ( case rendTimeType of ( 1:(sFrame = "frame:#current ") 2:(sFramerange = "framerange:#active ") 3:(sFromframe = "fromframe:" + rendStart as string + " "; sToframe = "toframe:" + rendEnd as string + " ") ) )--end if else roll_GlobalSettings.chbTimeOutput.checked == true if roll_GlobalSettings.chbOutputSize.checked == true then ( sOutputwidth = "outputwidth:" + roll_GlobalSettings.spnWidth.value as string + " " sOutputHeight = "outputheight:" + roll_GlobalSettings.spnHeight.value as string + " " ) else -- get width and height from file ( sOutputwidth = "outputwidth:" + renderWidth as string +" " sOutputHeight = "outputheight:" + renderHeight as string + " " )--end if else roll_GlobalSettings.chbOutputSize.checked == true if roll_GlobalSettings.chbSave.checked == true then ( outputpath = roll_GlobalSettings.edtSavePath.text +"\\" filetype = roll_GlobalSettings.ddlFileType.items[roll_GlobalSettings.ddlFileType.selection] maxfolder = "" if roll_GlobalSettings.chbFolder.checked == true do ( maxfolder = (getFilenameFile maxFileName) as string +"\\") prefix = "" if roll_GlobalSettings.chbPrefix.checked do ( prefix = (getFilenameFile maxFileName) as string) filename = roll_GlobalSettings.edtFileName.text makeDir (outputpath + maxfolder) sOutputfile = "outputfile:\"" + outputpath + maxfolder + prefix + filename + filetype + "\" " tokens = filterString sOutputfile "\\" sOutputfile = "" for i = 1 to tokens.count do ( if i != 1 then (sOutputfile += "\\\\" + tokens[i]) else (sOutputfile += tokens[i]) ) ) else -- geen save overwrites, dus we halen deze op van de file zelf ( if rendSaveFile do (sOutputfile = "outputfile:\"" + rendOutputFilename+ "\" ") )--end if else roll_GlobalSettings.chbSave.checked == true --other params sVfb = "vfb:" + "false " sRender = "render " + sFrame + sCamera + sFramerange + sFromframe + sToframe + sOutputwidth + sOutputHeight + sOutputfile + sVfb print sRender execute sRender --actionMan.executeAction 0 "50031" -- Render: Render -- not same as render() --render camera: frame:|#current framerange:|#active fromframe: