View Single Post
Old 14-01-2011, 06:04 AM   #11
NextDesign
Technical Director
 
NextDesign's Avatar
 
Join Date: Feb 2004
Posts: 2,982
Thanks: 33
Thanked 532 Times in 471 Posts
Default

Wow, it seems this script has attracted quite a bit of attention

Here is a fixed version that will allow rendering in multiple renderers, as well as work in Maya 2011!

Code:
// Batch rendering workaround - John Mather (NextDesign)
string $filename = "render";
string $cameraName = "persp";

int $startFrame = 1;
int $endFrame = 3;

string $directory = (`workspace -q -rd` + "images/");

for ($i = $startFrame; $i <= $endFrame; $i++)
{
    currentTime $i;

    // Old version
    // render -x `getAttr defaultResolution.width` -y `getAttr defaultResolution.height` $cameraName;
    
    // New version - supports MR and other renderers!    
    renderWindowRender redoPreviousRender renderView;
    
    string $concatFilename = $directory + $filename + "." + $i;

    if (`getApplicationVersionAsFloat` >= 2011)
        // Thanks to nowayfra on creativecrash for his workaround
        catch(eval(renderWindowSaveImageCallback ("renderView", $concatFilename, `getAttr defaultRenderGlobals.imageFormat`)));
    else
        renderWindowSaveImageCallback ("renderView", $concatFilename, `getAttr defaultRenderGlobals.imageFormat`);

    print ("Saved " + $concatFilename + "\n");
}

print ("Completed rendering of " + ($endFrame - $startFrame) + " frames.\n");
P.s. Many thanks goes out to nowayfra on CreativeCrash for his Maya 2011 fix! (http://www.creativecrash.com/forums/...on_post_306312)

Edit: Fixed a small bug that would stop all frames from being rendered.
__________________
Imagination is more important than knowledge.

Last edited by NextDesign : 24-01-2011 at 12:14 AM.
NextDesign is offline   Reply With Quote
The Following 5 Users Say Thank You to NextDesign For This Useful Post:
Antonin Ganner (06-02-2012), BabyDuck (22-02-2011), bullet1968 (14-01-2011), MystaPaul (25-01-2011), tweetytunes (18-02-2011)