Python
Batch Rib Render


main index


Introduction

When a script performs a "batch process" it does so by either:
  - directly editing a sequence of files, or
  - by writing a text file that indirectly references a number of files.

For this assignment you are to write a python script, named "make_batch_render.py", that when double clicked, or executed from a terminal, will create a script named "run_batch_render" containing a sequence of commands of the following form.


export RMANTREE=/Applications/Pixar/RenderManProServer-22.3
export MAYA_USER_DIR=$NETHOME/maya
unset LD_LIBRARY_PATH
"$RMANTREE/bin/prman" -cwd "H:/maya/projects/tech312" -t:all -progress "H:/maya/projects/tech312/renderman/rib/test/v001_t01/perspShape.0001.rib"
"$RMANTREE/bin/prman" -cwd "H:/maya/projects/tech312" -t:all -progress "H:/maya/projects/tech312/renderman/rib/test/v001_t01/perspShape.0002.rib"
"$RMANTREE/bin/prman" -cwd "H:/maya/projects/tech312" -t:all -progress "H:/maya/projects/tech312/renderman/rib/test/v001_t01/perspShape.0003.rib"

The purpose of the "run_batch_render" script is to render a sequence of .rib files that have been generated by Maya. The advantages of "off-line" rendering will be discussed in class. The purpose of the two exports, the unset shell commands and the -cwd, -t:all and -progress flags will also be discussed in class.


Algorithm

The following algorithm, operating recipe, assumes the "make_batch_render.py" script has been saved in the same directory as ".rib" files that are intended to be batch rendered. However, the run_batch_render (or run_batch_render.bat) script that is generated by your python script MUST be saved in the current Maya project directory, for example,

    H:/maya/projects/tech312

  1   determine the full path to the ribs directory,
  2   create a list of the full paths of the ".rib" files,
  3   sort the list,
  4   get the name of the first image (excluding the numeric and ".exr" extensions,
  5   depending on the OS open a file named "run_batch_render" or "run_batch_render.bat",
  6   write the first three lines,
  7   write the sequence of "prman" commands for each .rib file to be rendered,
  Finally, close the file and depending on the OS give it "execute" permissions.