RUSH 3RD PARTY RENDER SCRIPTS
(C) Copyright 1995,2000 Greg Ercolano. All rights reserved.
V 102.41 06/29/04

3rd Party Render Scripts
Houdini, Maya, Softimage, Renderman are all registered trademark names of their respective software manufacturer's products.

  Houdini Submit/Render Script  

    A simple example of separate submit and render scripts. To keep the examples simple, there's no frame batching or any fancy stuff.

    Change the red text to names relevant on your system.

      CSH: Houdini Submit Script
      #!/bin/csh -f
      
      # houdini-submit.csh
      
      ##############################
      #  S U B M I T  S C R I P T  #
      ##############################
                                                                                           
      rush -submit << EOF
          title      HOUDINI
          ram        1
          frames     1-20
          logdir     //tahoe/net/tmp/logs
          command    csh //path/to/houdini-render.csh MyScene
          cpus       +any=10@100
      EOF
      exit 0
              

      CSH: Houdini Render Script
      #!/bin/csh -f
      
      # houdini-render.csh
      
      ##############################
      #  R E N D E R  S C R I P T  #
      ##############################
      
      # Set up your houdini environment variables here
      
      echo "--- Working on frame $RUSH_FRAME - `date`"
      
      ### YOUR RENDER COMMAND(S) HERE
      set ren = $1
      hscript /jobs/MYJOB/hip/mytest.hip << EOF
          opcf /out
          echo setting visibility
          opscript $ren > $tmpdir/set_vis_in.$$
          opparm $ren trange ( on ) f ( $RUSH_FRAME $RUSH_FRAME 1 ) 
          opparm $ren background ( off )
          echo opparm $ren background ( off )
          render -V $ren
          quit
      EOF
      set err = $status
      
      # Rush exit codes: 0=DONE 1=FAIL 2=RETRY
      if ( $err ) then
          echo --- FAIL; exit 1
      else
          echo --- DONE; exit 0
      endif
              

  BMRT Submit/Render Script  
    These are simple examples of combination submit/render scripts; there's a Perl version, and a DOS batch version. Use either one; the perl version is more portable.

    To keep the examples simple, there's no frame batching or any fancy stuff.

    Be sure to change the red text to names relevant on your system.

      PERL: BMRT Submit / Render
      #!/usr/bin/perl
      
      # SIMPLE BMRT PERL SUBMIT EXAMPLE
      #     Shows the easiest way to make a self contained
      #     submit/render script. This script should work on Windows or Unix.
      #
      
      $|=1;
      umask(0);
      
      # NEED ABSOULUTE PATH TO SELF
      my $self = $0;
      if ( $self !~ m%^[/\\]% && $self !~ m%^[a-zA-Z]:% )
          { my $pwd=`pwd`; chomp($pwd); $self = "$pwd/$0"; }
      
      # ENVIRONMENT SETTINGS
      $G::iswindows  = ( defined($ENV{OS}) && $ENV{OS} eq "Windows_NT" ) ? 1 : 0;
      if ( $G::iswindows )
      {
          # WINDOWS ENVIRONMENT SETTINGS -- CHANGE AS NEEDED
          $ENV{BMRTTREE} = "c:/BMRT";
          $ENV{PATH}     = "$ENV{PATH};$ENV{BMRTTREE}/bin"
      }
      else
      {
          # UNIX ENVIRONMENT SETTINGS -- CHANGE AS NEEDED
          $ENV{BMRTTREE} = "/usr/local/BMRT";
          $ENV{PATH}     = "$ENV{PATH}:$ENV{BMRTTREE}/bin"
      }
      
      # MAIN
      {
          if ( $#ARGV < 1 )
          {
      	print STDERR "USAGE\n".
      		     "    $0 ribpath framerange\n\n".
      		     "EXAMPLE\n".
      		     "    $self //tahoe/net/tmp/ribs/foo.%04d.rib 1-50\n\n";
      	exit(1);
          }
      
          # INVOKED AS A RENDER SCRIPT?
          #    Then rush is calling us to render a frame.
          #    Create BMRT command line and run it, checking for errors.
          #
          if ( $ARGV[0] eq "-render" )
          {
      	shift(@ARGV);
      	my ($ribpath) = @ARGV;
      	my $ribfilename = sprintf($ribpath, $ENV{RUSH_FRAME});
      
      	my $cmd = "rendrib $ribfilename";
      
      	print "RIBFILE=$ribfilename\n".
                    "  FRAME=$ENV{RUSH_PADFRAME}\n".
      	      "\n".
                    "Executing: $cmd\n";
      
      	my $exitcode = system($cmd) >> 8;
      
      	if ( $exitcode ) 
      	{
      	    print STDERR "BMRT FAILED: EXITCODE=$exitcode\n";
      	    exit(1);	# "Fail"
      	}
      
      	print STDERR "BMRT SUCCEEDED: EXITCODE=$exitcode\n"; 
      	exit(0);	# "Done"
          }
          else
          {
      	# INVOKED AS A SUBMIT SCRIPT?
      	#     Get args from command line, and submit to rush
      	#
      	my ($ribpath, $frames) = @ARGV;
      	my $ribdir = $ribpath; $ribdir =~ s%[/\\][^\\/]*$%%;	# "/foo/bar.%04d.rib" -> "/foo"
      
      	unless ( open(SUBMIT, "|rush -submit") )
      	    { print STDERR "$0: 'rush -submit': $!\n"; exit(1); }
      	print SUBMIT <<"EOF";
      	    title      BMRT
      	    ram        10
      	    frames     $frames
      	    logdir     $ribdir/%s
      	    command    perl $self -render $ribpath
      	    cpus       +any=10\@100
      EOF
      	close(SUBMIT);
      	if ( $? >> 8 ) 
      	    { print STDERR "-- submit failed --\n"; exit(1); }
      	exit(0);
          }
          #NOTREACHED
      }
              

    Here's a similar script written as a DOS batch script. Because DOS is very limited in its string manipulation ability (it practically has none), this script is not as featured as the Perl version.

    Be sure to change the red text to names relevant on your system.

      DOS: BMRT Submit / Render
      @echo off
      
      REM ###
      REM ### DOS BATCH -- BMRT SUBMIT/RENDER SCRIPT
      REM ###              Works on Windows *only*
      REM ###
      
      REM ### USER SHOULD CHANGE THESE!!
      REM ###    Use UNC style absolute pathnames with front "/" slashes.
      REM ###
      set BMRTTREE=c:/bmrt
      set   RIBDIR=//tahoe/net/tmp/ribs
      set   LOGDIR=//tahoe/net/tmp/ribs/logs
      set     CPUS=+any=10@100
      
      if "%1"=="-render" goto RENDER
      
      REM ######################
      REM ### SUBMIT SECTION ###
      REM ######################
      :SUBMIT
      set TMPDIR=c:\temp
      set SUBMIT=c:\temp\$$$.bat
      set SELF=%0
      set SELF=%SELF:\=/%
      (
      echo    title      TEST
      echo    ram        1
      echo    frames     1-20
      echo    logdir     %LOGDIR%
      echo    command    cmd /c %SELF% -render
      echo    cpus       %CPUS%
      ) | rush -submit > %SUBMIT%
      if %ERRORLEVEL% GEQ 1 goto DONE
      call %SUBMIT%
      del %SUBMIT%
      echo RUSH_JOBID is %RUSH_JOBID%
      start /b irush %RUSH_JOBID% -button Frames
      goto DONE
      
      
      REM ######################
      REM ### RENDER SECTION ###
      REM ######################
      :RENDER
      echo RIBDIR=%RIBDIR%
      @echo on
      rendrib %RIBDIR%/foo.%RUSH_PADFRAME%.rib
      @set ERR=%ERRORLEVEL%
      @echo off
      if %ERR% GTR 0   goto FAIL
      echo --- BMRT SUCCEEDS: EXITCODE=%ERR%
      exit 0
      
      :FAIL
      echo --- BMRT FAILED: EXITCODE=%ERR%
      exit 1
      
      :DONE
              

  Maya Submit / Render Script  
    These are simple examples of combination submit/render scripts; there's a Perl version, and a DOS batch version. Use either one; the perl version is more portable.

    To keep the examples simple, there's no frame batching or any fancy stuff.

    Be sure to change the red text to names relevant on your system.

      PERL: Maya Submit / Render
      #!/usr/bin/perl
      
      # SIMPLE MAYA PERL SUBMIT EXAMPLE
      #     Shows the easiest way to make a self contained
      #     submit/render script. This script should work on Windows or Unix.
      #
      
      $|=1;
      umask(0);
      
      # NEED ABSOULUTE PATH TO SELF
      my $self = $0;
      if ( $self !~ m%^[/\\]% && $self !~ m%^[a-zA-Z]:% )
          { my $pwd=`pwd`; chomp($pwd); $self = "$pwd/$0"; }
      
      # MAIN
      {
          if ( $#ARGV < 1 )
          {
      	print STDERR "USAGE\n".
      		     "    $0 scenefile framerange [imagedir]\n\n".
      		     "EXAMPLE\n".
      		     "    $self //tahoe/net/tmp/scenes/foo.ma 1-20,2\n\n";
      	exit(1);
          }
      
          # INVOKED AS A RENDER SCRIPT?
          #    Then rush is calling us to render a frame.
          #    Create maya command line and run it, checking for errors.
          #
          if ( $ARGV[0] eq "-render" )
          {
      	shift(@ARGV);
      	my ($scenefile,$imagedir) = @ARGV;
      	$imagedir = ( $imagedir eq "-" ) ? "" : "-rd $imagedir";
      
      	my $cmd = "render -s $ENV{RUSH_FRAME} -e $ENV{RUSH_FRAME} $imagedir $scenefile";
      
      	print "   SCENE=$scenefile\n".
                    "IMAGEDIR=$scenefile\n".
                    "   FRAME=$ENV{RUSH_PADFRAME}\n".
      	      "\n".
                    "Executing: $cmd\n";
      
      	my $exitcode = system($cmd) >> 8;
      
      	if ( $exitcode ) 
      	{
      	    print STDERR "MAYA FAILED: EXITCODE=$exitcode\n";
      	    exit(1);	# "Fail"
      	}
      
      	print STDERR "MAYA SUCCEEDED: EXITCODE=$exitcode\n"; 
      	exit(0);	# "Done"
          }
          else
          {
      	# INVOKED AS A SUBMIT SCRIPT?
      	#     Get args from command line, and submit to rush
      	#
      	my ($scenefile,$frames,$imagedir) = @ARGV;
      	if ( $imagedir eq "" ) 
      	    { $imagedir = "-"; }
      
      	# MAKE SURE SCENEFILE AND LOGDIR EXISTS
              if ( ! -e "$scenefile" )
                  { print "$scenefile: does not exist\n"; exit(1); }
              if ( ! -d "$scenefile.log" )
              {
                  unless ( mkdir("$scenefile.log", 0777) )
                      { print STDERR "mkdir '$scenefile.log': $!\n"; exit(1); }
              }
      
      	# SUBMIT THE JOB
      	#    Pipe the submit commands into 'rush -submit'.
      	#
      	unless ( open(SUBMIT, "|rush -submit") )
      	    { print STDERR "$0: 'rush -submit': $!\n"; exit(1); }
      	print SUBMIT <<"EOF";
      	    title      MAYA
      	    ram        10
      	    frames     $frames
      	    logdir     $scenefile.log/%s
      	    command    perl $self -render $scenefile $imagedir
      	    cpus       +any=10\@100
      EOF
      	# CHECK IF SUBMIT SUCCEEDED
      	#    If failed, exit non-zero, error message on stderr.
      	#
      	close(SUBMIT);
      	if ( $? >> 8 ) 
      	    { print STDERR "-- submit failed --\n"; exit(1); }
      	exit(0);
          }
          #NOTREACHED
      }
              

    Here's a similar script written as a DOS batch script. Because DOS is very limited in its string manipulation ability (it practically has none), this script is not as featured as the Perl version.

    Be sure to change the red text to names relevant on your system.

      DOS: Maya Submit / Render
      @echo off
      
      REM ###
      REM ### DOS BATCH -- MAYA SUBMIT/RENDER SCRIPT
      REM ###              Works on Windows *only*
      REM ###
      
      REM ### USER SHOULD CHANGE THESE!!
      REM ###    Use UNC style absolute pathnames with front "/" slashes.
      REM ###
      set   MAYASCENE=//tahoe/net/tmp/scenes/foo.mb
      set MAYAPROJECT=//tahoe/net/tmp
      set  MAYALOGDIR=//tahoe/net/tmp/scenes/foo.mb.log
      set    MAYACPUS=+any=10@100
      
      
      if "%1"=="-render" goto RENDER
      
      REM ######################
      REM ### SUBMIT SECTION ###
      REM ######################
      :SUBMIT
      set TMPDIR=c:\temp
      set SUBMIT=c:\temp\$$$.bat
      set SELF=%0
      set SELF=%SELF:\=/%
      (
      echo    title      TEST
      echo    ram        1
      echo    frames     1-20
      echo    logdir     %MAYALOGDIR%
      echo    command    cmd /c %SELF% -render
      echo    cpus       %MAYACPUS%
      ) | rush -submit > %SUBMIT%
      if %ERRORLEVEL% GEQ 1 goto DONE
      call %SUBMIT%
      del %SUBMIT%
      echo RUSH_JOBID is %RUSH_JOBID%
      start /b irush
      goto DONE
      
      
      REM ######################
      REM ### RENDER SECTION ###
      REM ######################
      :RENDER
      echo MAYA SCENE=%MAYASCENE%
      echo MAYA PROJECT=%MAYAPROJECT%
      @echo on
      @echo EXECUTING MAYA:
      render -verbose 1 -proj %MAYAPROJECT% -s %RUSH_FRAME% -e %RUSH_FRAME% -b 1 %MAYASCENE%
      @set ERR=%ERRORLEVEL%
      @echo off
      if %ERR% EQU 128 goto REQUEUE128
      if %ERR% GTR 0   goto FAIL
      echo --- MAYA SUCCEEDS: EXITCODE=%ERR%
      exit 0
      
      :FAIL
      echo --- MAYA FAILED: EXITCODE=%ERR%
      exit 1
      
      
      :REQUEUE128
      echo --- MAYA INDICATES LICENSE ERROR (EXIT 128)
      echo --- ADDING THIS MACHINE AS NEVERHOST AND REQUEING
      rush -fu an %RUSH_HOSTNAME%
      exit 2
      
      :DONE
              

  Renderman Submit/Render Script  
    These are simple examples of combination submit/render scripts; there's a Perl version, and a DOS batch version. Use either one; the perl version is more portable.

    To keep the examples simple, there's no frame batching or any fancy stuff.

    Change the red text to names relevant on your system.

      PERL: Renderman Submit / Render
      #!/usr/bin/perl
      
      # SIMPLE RENDERMAN PERL SUBMIT EXAMPLE
      #     Shows the easiest way to make a self contained
      #     submit/render script. This script should work on Windows or Unix.
      #
      
      $|=1;
      umask(0);
      
      # NEED ABSOULUTE PATH TO SELF
      my $self = $0;
      if ( $self !~ m%^[/\\]% && $self !~ m%^[a-zA-Z]:% )
          { my $pwd=`pwd`; chomp($pwd); $self = "$pwd/$0"; }
      
      # ENVIRONMENT SETTINGS
      $G::iswindows  = ( defined($ENV{OS}) && $ENV{OS} eq "Windows_NT" ) ? 1 : 0;
      if ( $G::iswindows )
      {
          # WINDOWS ENVIRONMENT SETTINGS -- CHANGE AS NEEDED
          $ENV{RMANTREE} = "c:/prman";
          $ENV{PATH}     = "$ENV{PATH};$ENV{RMANTREE}/bin"
      }
      else
      {
          # UNIX ENVIRONMENT SETTINGS -- CHANGE AS NEEDED
          $ENV{RMANTREE} = "/usr/local/prman";
          $ENV{PATH}     = "$ENV{PATH}:$ENV{RMANTREE}/bin"
      }
      
      # MAIN
      {
          if ( $#ARGV < 1 )
          {
      	print STDERR "USAGE\n".
      		     "    $0 ribpath framerange\n\n".
      		     "EXAMPLE\n".
      		     "    $self //tahoe/net/tmp/ribs/foo.%04d.rib 1-50\n\n";
      	exit(1);
          }
      
          # INVOKED AS A RENDER SCRIPT?
          #    Then rush is calling us to render a frame.
          #    Create Renderman command line and run it, checking for errors.
          #
          if ( $ARGV[0] eq "-render" )
          {
      	shift(@ARGV);
      	my ($ribpath) = @ARGV;
      	my $ribfilename = sprintf($ribpath, $ENV{RUSH_FRAME});
      
      	my $cmd = "rendrib $ribfilename";
      
      	print "RIBFILE=$ribfilename\n".
                    "  FRAME=$ENV{RUSH_PADFRAME}\n".
      	      "\n".
                    "Executing: $cmd\n";
      
      	my $exitcode = system($cmd) >> 8;
      
      	if ( $exitcode ) 
      	{
      	    print STDERR "RENDERMAN FAILED: EXITCODE=$exitcode\n";
      	    exit(1);	# "Fail"
      	}
      
      	print STDERR "RENDERMAN SUCCEEDED: EXITCODE=$exitcode\n"; 
      	exit(0);	# "Done"
          }
          else
          {
      	# INVOKED AS A SUBMIT SCRIPT?
      	#     Get args from command line, and submit to rush
      	#
      	my ($ribpath, $frames) = @ARGV;
      	my $ribdir = $ribpath; $ribdir =~ s%[/\\][^\\/]*$%%;	# "/foo/bar.%04d.rib" -> "/foo"
      
      	unless ( open(SUBMIT, "|rush -submit") )
      	    { print STDERR "$0: 'rush -submit': $!\n"; exit(1); }
      	print SUBMIT <<"EOF";
      	    title      RENDERMAN
      	    ram        10
      	    frames     $frames
      	    logdir     $ribdir/%s
      	    command    perl $self -render $ribpath
      	    cpus       +any=10\@100
      EOF
      	close(SUBMIT);
      	if ( $? >> 8 ) 
      	    { print STDERR "-- submit failed --\n"; exit(1); }
      	exit(0);
          }
          #NOTREACHED
      }
              

    Here's a similar script written as a DOS batch script. Because DOS is very limited in its string manipulation ability (it practically has none), this script is not as featured as the Perl version.

    Change the red text to names relevant on your system.

      DOS: Renderman Submit / Render
      @echo off
      
      REM ###
      REM ### DOS BATCH -- RENDERMAN SUBMIT/RENDER SCRIPT
      REM ###              Works on Windows *only*
      REM ###
      
      REM ### USER SHOULD CHANGE THESE!!
      REM ###    Use UNC style absolute pathnames with front "/" slashes.
      REM ###
      set RMANTREE=c:/bmrt
      set   RIBDIR=//tahoe/net/tmp/ribs
      set   LOGDIR=//tahoe/net/tmp/ribs/logs
      set     CPUS=+any=10@100
      
      if "%1"=="-render" goto RENDER
      
      REM ######################
      REM ### SUBMIT SECTION ###
      REM ######################
      :SUBMIT
      set TMPDIR=c:\temp
      set SUBMIT=c:\temp\$$$.bat
      set SELF=%0
      set SELF=%SELF:\=/%
      (
      echo    title      TEST
      echo    ram        1
      echo    frames     1-20
      echo    logdir     %LOGDIR%
      echo    command    cmd /c %SELF% -render
      echo    cpus       %CPUS%
      ) | rush -submit > %SUBMIT%
      if %ERRORLEVEL% GEQ 1 goto DONE
      call %SUBMIT%
      del %SUBMIT%
      echo RUSH_JOBID is %RUSH_JOBID%
      start /b irush %RUSH_JOBID% -button Frames
      goto DONE
      
      
      REM ######################
      REM ### RENDER SECTION ###
      REM ######################
      :RENDER
      echo RIBDIR=%RIBDIR%
      @echo on
      prman %RIBDIR%/foo.%RUSH_PADFRAME%.rib
      @set ERR=%ERRORLEVEL%
      @echo off
      if %ERR% GTR 0   goto FAIL
      echo --- RENDERMAN SUCCEEDS: EXITCODE=%ERR%
      exit 0
      
      :FAIL
      echo --- RENDERMAN FAILED: EXITCODE=%ERR%
      exit 1
      
      :DONE
              

  Softimage Submit/Render Script  
    A simple example of separate submit and render scripts. To keep the examples simple, there's no frame batching or any fancy stuff.

    Change the red text to names relevant on your system.

      CSH: Softimage Submit Script
      #!/bin/csh -f
      
      # soft-submit.csh
      
      ##############################
      #  S U B M I T  S C R I P T  #
      ##############################
                                                                                           
      rush -submit << EOF
          title      SOFTIMAGE
          ram        1
          frames     1-20
          logdir     //tahoe/net/tmp/logs
          command    csh //path/to/soft-render.csh
          cpus       +any=10@100
      EOF
      exit 0
              

      CSH: Softimage Render Script
      #!/bin/csh -f
      
      # soft-render.csh
      
      ##############################
      #  R E N D E R  S C R I P T  #
      ##############################
      
      # Softimage environment variables
      #
      source /usr/Softimage3.9/.softimage39
      setenv SI_CUSTOM_REFINE_TEMP_PATH  ${RUSH_TMPDIR}
      setenv PARTICLE_TMPDIR             ${RUSH_TMPDIR}
      
      echo "--- Working on frame $RUSH_FRAME - `date`"
      
      ### YOUR RENDER COMMAND(S) HERE
      setenv SI_DBDIR //tahoe/net/tmp/softproject
      soft -R BallCueTst_01.1-0.dsc		\
           -d Test 				\
           -s ${RUSH_FRAME} ${RUSH_FRAME} 1
      set err = $status
                                                                                           
      # Rush exit codes: 0=DONE 1=FAIL 2=RETRY
      if ( $err ) then
          echo --- FAIL; exit 1
      else
          echo --- DONE; exit 0
      endif
              

      CSH: Xsi Submit + Render Script
      #!/bin/csh -f
      
      # SUBMIT-SOFT-SIMPLE
      #     A simple Rush submit script for xsi;
      #     submits self to render on remotes.
      #
      
      set self = "$0"
      if ( $self !~ /* ) then
          echo This script must be invoked with an absolute path
          exit 1
      endif
      
      ### No args? Submit job that invokes self with -render argument
      if ( "$1" == "" ) then
          if ( $?RUSH_ISDAEMON ) exit 1 # avoid recursion
          rush -submit << EOF
              title      SOFTIMAGE
              ram        1
              frames     1-20
              logdir     /net/tmp/logs
              command    $self -render
              cpus       +any=10@100
      EOF
          exit 0
      endif
                                                                                         
      ### Running on remote? Invoke xsi to render the frame
      if ( "$1" == "-render" ) then
          xsi -r \
              -scene "/net/jobs/MiscReel/Scenes/tableHourGlass3.scn" \
              -pass "camMv" \
              -startframe $RUSH_FRAME \
              -endframe $RUSH_FRAME \
              -verbose "full"
      
          set err = $status
      
          # Rush exit codes: 0=DONE 1=FAIL 2=RETRY
          if ( $err ) then
              echo --- FAIL; exit 1
          else
              echo --- DONE; exit 0
          endif
      endif
      
      ### Should never get here
      echo "unknown argument: $1"
      exit 1