Tagged: macintosh

Creating a Maya batch render script

Creating a Maya batch render script for a PC using Windows has always been straightforward in my experience. You simply write a text file with the following code:

render /path/to/myFile.mb

Make the file executable by changing the extension to .bat. Double click the file to launch the render.

The renderer will use settings that were selected when the project was saved. Those settings can be over-ridden with render flags. See Render Flags below for render flags and options.

For the Mac, it can be slightly less straightforward. Follow these instructions, found on Autodesk, The Area

Issue

You are on Mac OS X and you want to render several files one after another using a batch script.

Solution

To batch render multiple scene files, you need to create a shell script, for example: myRender.sh.

1. Using a text editor (Applications > Textedit), enter the render command for each individual scene on a separate line.

#!/bin/bash
Render –r sw scene1.mb
Render –r sw scene2.mb
Render –r sw scene3.mb

In some cases, you may need to enter the complete path of the Render command. It is located here:

/Applications/Autodesk/maya2009/Maya.app/Contents/bin/Render
(of course, different for later versions of the software)

2. Save the file on your desktop as: myRender.sh.

3. You will need to change the file permissions of myRender.sh to 755.

Open the Maya Terminal (Applications > Autodesk > Maya2009 > Maya Terminal) and type:

chmod 755 /Users/YOUR-USERNAME/Desktop/myRender.sh

4. Now run the script from the Maya terminal by typing:

/Users/YOUR-USERNAME/Desktop/myRender.sh

(note! A shortcut to typing file paths in the terminal: Just drag the file to the terminal window!)

Code:

 
#!/bin/bash /Applications/Autodesk/maya2009/Maya.app/Contents/bin/Render -rd /path/to/render/output/folder /path/to/myFile.mb

Render Flags

Render flags are “options” code. For example in Render -rd, -rd is the flag, which allows you to set the exact render directory, i.e. where your rendered images will be saved.

 
Render -rd /path/to/render/output/folder

Do a search in the help for more render flags (options):
render -h in the terminal.

 
/Applications/Autodesk/maya2009/Maya.app/Contents/bin/Render -h

Popular Render Flags:

-proj
#Use this flag to ensure you are rendering to the proper project: -proj /path/to/projectDirectory

-s, -e
#specify start and end frames: -s 0 -e 100

-r
# Specify renderer: -r mr for mental ray (or : sw, hw, etc)

-rt
# Render threads, specify number of cpu threads, I use -rt 8 for my Mac Pro Quad (Mental Ray only)

-rl
# Specify render layer by name: -rl layer1

-cam
#Specify camera to render by name

-rd
# specify render image path: -rd /path/ to/image/folder/

-im
# specify image name: -im myImageName

If you are using Render layers use the following flags and setup:

-rl boolean|name(s)

Set up like this:

Render -rl layer1 /path/to/file1.mb
Render -rl layer2 /path/to/file1.mb

More info on render flags:

Maya render flags: http://www.pdipierro.com/tutorials/MayaRenderFlags.html

Also see
http://oliverwolfson.com/maya-render-settings-file-name-prefix/