#!/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 = "-"; }
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
close(SUBMIT);
if ( $? >> 8 )
{ print STDERR "-- submit failed --\n"; exit(1); }
exit(0);
}
#NOTREACHED
}
|