Rendering one frame at a time without writing a gazillion line’s batch

The other day I was rendering a sequence of 74 frames with many render layers.

I usually render at night while sleeping and when I get up I do a quick comp to check if everything is fine. The problem is that Maya renders one render layer at a time for the entire sequence so if you stop it after 50 frames you’ll have nothing to comp.

The workaround was doing a batch file to render a frame at a time, but I had to write 74 lines and it’s quite susceptible to human errors. So I ended with a simple batch file that make a loop!

@REM initialize variables

@SET startFrame=1
@SET endFrame=60
@SET proj=S:\wiskyPlanet
@SET scene=wiskyPlanet_anim_017_A3.mb
@SET mayaInstallDir=C:\Program Files\Autodesk\Maya 2011 Subscription Advantage Pack
@SET verbose=5
:while

@REM test condition
@IF %startFrame% GTR %endFrame% (GOTO wend)

@REM procedure where condition is "true"
@echo =====================================
@echo frame to render is frame %startFrame% (of %endFrame%)
@echo =====================================
"%mayaInstallDir%\bin\Render.exe" -r mr -rt 4 -v %verbose% -s %startFrame% -e %startFrame% -proj "%proj%" "%proj%\scenes\%scene%"


@REM set new test value
@SET /a startFrame=startFrame+1

@REM loop
@GOTO while

:wend


@PAUSE

You can set the variable in the first part:

Start frame
End Frame
Project Directory
Scene Name
Directory where Maya is installed
Quantity of detail of the log (1 to 6)

@SET startFrame=1
@SET endFrame=60
@SET proj=S:\wiskyPlanet
@SET scene=wiskyPlanet_anim_017_A3.mb
@SET mayaInstallDir=C:\Program Files\Autodesk\Maya 2011 Subscription Advantage Pack
@SET verbose=5

and this is the string with the render command, you can add whatever flag you want (like -rl for render layers ecc ecc)

"%mayaInstallDir%\bin\Render.exe" -r mr -rt 4 -v %verbose% -s %startFrame% -e %startFrame% -proj "%proj%" "%proj%\scenes\%scene%"

And this is the same for OSX (and linux i guess)

#!/bin/bash
for i in {1..60}
do
 echo $i
 Render -r mr -rt 4 -s $i -e $i -proj "MayaProjectPath" "MayaSceneFileName"
done

Happy rendering!


About this entry