Dave Girard's 101 Autodesk® Maya® Tips is now available in Kindle, interactive iPad edition and DRM-free EPUB/PDF editions. Work faster, cry less. Read more about the ebook.




Follow cgbeige on Twitter

Topics by tag:



Recently published articles by Dave G:



Free downloads by Dave G:



Mac OS X-only downloads:

Make An Interactive Render Shell Script for OS X and Linux

With relatively no knowledge of shell scripting, it’s easy to make an interactive shell script that takes your input and turns them into variables. It’s perfect for making a render batch script, where you often have a lot of constants (your renderer, threads, etc.) that you don’t want to type, but you have something like the frame end and start points that you want to specify on a per-render basis. There are some GUI utilities that do this but the command line method uses no additional resources and lets you tell it exactly what your variables will be from now on. Just add some prompts with “echo” and that will look like it asks for input which is specified with “read”:

#!/bin/bash
echo "start frame:"
read startFrame;
echo "end frame:"
read endFrame;

/Applications/Autodesk/maya2012/Maya.app/Contents/bin/render -r vray -s $startFrame -e $endFrame -cam persp -threads 24 "$@"

The variable is the part after “read” so that render command at the end takes the path input ($@) and sends it to the render command with your input variables. In C or shell scripts, variables are declared without the $ at the start but in MEL, they are declared with the $. The double quotes around the variables ensure that any spaces in the names or paths will not cause problems for the shell, which can trip on those otherwise. That simple shell script makes for a pretty nice little tool:

Grab a copy of my vray render shell script here, if you want a template that has proper executable permissions to play with.

Update: changed code since it didn’t work with multiline and files with spaces in the name.

0 notes | Permalink