// Batch rendering workaround V3 - John Mather (NextDesign) // Author page: https://www.creativecrash.com/users/john-mather // Check for updates here: https://simplymaya.com/forum/showthread.php?p=318227 string $filename = "render"; int $startFrame = 1; int $endFrame = 24; string $directory = (`workspace -q -rd` + "images/"); // check for render panel. Found here: https://www.creativecrash.com/forums/mel/topics/error-object-not-found-renderview string $renderPanel; string $renderPanels[] = `getPanel -scriptType "renderWindowPanel"`; if(size($renderPanels)) $renderPanel = $renderPanels[0]; else { $renderPanel = `scriptedPanel -type "renderWindowPanel" -unParent renderView`; scriptedPanel -e -label "Render View" $renderPanel; } for ($i = $startFrame; $i <= $endFrame; $i++) { currentTime $i; renderWindowRender redoPreviousRender renderView; string $concatFilename = $directory + $filename + "." + $i; if (`getApplicationVersionAsFloat` >= 2011) // Thanks to nowayfra on creativecrash for his workaround catch(eval(renderWindowSaveImageCallback ($renderPanel, $concatFilename, `getAttr defaultRenderGlobals.imageFormat`))); else renderWindowSaveImageCallback ($renderPanel, $concatFilename, `getAttr defaultRenderGlobals.imageFormat`); print ("Saved " + $concatFilename + "\n"); } print ("Completed rendering of " + (($endFrame - $startFrame) + 1) + " frames.\n");
// Batch rendering workaround V4 - John Mather (NextDesign) // Author page: https://www.creativecrash.com/users/john-mather // Check for updates here: https://simplymaya.com/forum/showthread.php?p=318227 string $filename = "render"; int $startFrame = 3; int $endFrame = 24; int $nFramePadLength = 4; // eg name.0000.ext (4 zeros) string $directory = (`workspace -q -rd` + "images/"); // check for render panel. Found here: https://www.creativecrash.com/forums/mel/topics/error-object-not-found-renderview string $renderPanel; string $renderPanels[] = `getPanel -scriptType "renderWindowPanel"`; if(size($renderPanels)) $renderPanel = $renderPanels[0]; else { $renderPanel = `scriptedPanel -type "renderWindowPanel" -unParent renderView`; scriptedPanel -e -label "Render View" $renderPanel; } // get the image format in the render globals int $format = `getAttr "defaultRenderGlobals.imageFormat"`; string $extension = ""; switch($format) { case 0: $extension = "gif"; break; case 1: $extension = "pic"; break; case 2: $extension = "rla"; break; case 3: $extension = "tif"; break; case 4: $extension = "tif"; break; case 5: $extension = "sgi"; break; case 6: $extension = "als"; break; case 7: $extension = "iff"; break; case 8: $extension = "jpg"; break; case 9: $extension = "eps"; break; case 10: $extension = "iff"; break; case 11: $extension = "cin"; break; case 12: $extension = "yuv"; break; case 13: $extension = "sgi"; break; case 19: $extension = "tga"; break; case 20: $extension = "bmp"; break; case 22: $extension = "mov"; break; case 30: $extension = "pntg"; break; case 31: $extension = "psd"; break; case 32: $extension = "png"; break; case 33: $extension = "pict"; break; case 34: $extension = "qtif"; break; case 35: $extension = "dds"; break; case 36: $extension = "psd"; break; } // start the progress bar global string $gMainProgressBar; progressBar -edit -beginProgress -isInterruptable true -status "Rendering..." -maxValue $endFrame $gMainProgressBar; for ($i = $startFrame; $i <= $endFrame; $i++) { // check for user termination if(`progressBar -query -isCancelled $gMainProgressBar`) break; currentTime $i; renderWindowRender redoPreviousRender renderView; // pad the frame number string $framePadded = $i; while (`size($framePadded)` < $nFramePadLength) $framePadded = ("0" + $framePadded); string $concatFilename = $directory + $filename + "." + $framePadded + "." + $extension; if (`getApplicationVersionAsFloat` >= 2011) // Thanks to nowayfra on creativecrash for his workaround catch(eval(renderWindowSaveImageCallback ($renderPanel, $concatFilename, `getAttr defaultRenderGlobals.imageFormat`))); else renderWindowSaveImageCallback ($renderPanel, $concatFilename, `getAttr defaultRenderGlobals.imageFormat`); progressBar -edit -step 1 -status ("Rendering frame " + (($i - $startFrame) + 1) + " of " + (($endFrame - $startFrame) + 1)) $gMainProgressBar; // update the progress bar print ("Saved " + $concatFilename + "\n"); } progressBar -edit -endProgress $gMainProgressBar; // clear the progress bar print ("Completed rendering of " + (($endFrame - $startFrame) + 1) + " frames.\n");
Hi kayveedeeoh, what do you mean by "grab all the settings from a render layer"? Do you just want all of the render layers to be batched out?Thanks Next Design.
A question:
How could I customize this to grab all the settings from a render layer, and render out multiple layers without having to babysit each one?
Hi kayveedeeoh, could you send me a test file? I'll take a look into it. Is the normal batch not working?That's exactly it yes.
Hey ctbram, it's due to an annoying little bug in 2011+ with the ImageFormats:Just out of curiosity, why do you have to call "renderWindowSaveImage" in the catch(eval(...)) block in maya 2011 or higher?
It still writes out the file, but since it throws an error, the scripts halts. The catch eval pretty much just states "I know there's a problem, just keep going."# Error: AttributeError: ImageFormats instance has no attribute 'oldOutf' #