View Single Post
# 22 19-04-2011 , 02:38 PM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Hey guys. I've figured out the problem. Here's the newest version. Also, please note that it renders out of the current camera (Ie. It renders out of the camera that renders when you press the render button [if that makes any sense user added image])

Code:
// 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");
Hope it helps guys!

-John


Imagination is more important than knowledge.

Last edited by NextDesign; 19-04-2011 at 10:00 PM.