#!/bin/perl -w use strict; sub WriteKeyFile { open( KEYFILE, '>' . $_[0] ) or die "Couldn't open file " . $_[0] . " for writing"; my $hashRef = $_[1]; my @keyList = sort keys %$hashRef; my $storedKeyList = $hashRef->{ "!!!perlTheOrderOfTheKeys!!!" }; if( defined $storedKeyList ) { my %storedKeyHash; foreach ( @$storedKeyList ) { $storedKeyHash{$_} = 1; } @keyList = grep { (!defined ($storedKeyHash{$_} )) and $_ ne "!!!perlTheOrderOfTheKeys!!!"; } @keyList; @keyList = ( @$storedKeyList, @keyList ); } foreach my $key ( @keyList ) { if( defined($hashRef->{$key}) ) { print KEYFILE "$key=" . $hashRef->{$key} . "\n" or die "Couldn't write key $key to key file"; } } close(KEYFILE); }; sub CountFileLines { open( LINEFILE, $_[0] ) or die "Couldn't open file " . $_[0] . " for reading"; my $count = 0; while( ) { $count++; } close(LINEFILE); return $count; } sub WriteCommandScript { open( CMDFILE, '>' . $_[0] ) or die "Couldn't open file " . $_[0] . " for writing"; my $sceneFile = $_[1]; my $frameNumber = $_[2]; my $outputPath = $_[3]; # Executables can't have spaces, so "PROGRA~1" is used instead of "Program Files" my $constantArgs = "C:/PROGRA~1/Alias/Maya6.5/bin/Render.exe -s $frameNumber -e $frameNumber -b 1 -ard 1.333330035 -rd $outputPath -pad 4"; print CMDFILE "$constantArgs -eaa 0 -mb false -im output_eaa_0_mb_0 \"$sceneFile\"\n"; print CMDFILE "$constantArgs -eaa 1 -mb false -im output_eaa_1_mb_0 \"$sceneFile\"\n"; print CMDFILE "$constantArgs -eaa 2 -mb false -im output_eaa_2_mb_0 \"$sceneFile\"\n"; print CMDFILE "$constantArgs -eaa 3 -mb false -im output_eaa_3_mb_0 \"$sceneFile\"\n"; print CMDFILE "$constantArgs -eaa 0 -mb true -im output_eaa_0_mb_1 \"$sceneFile\"\n"; print CMDFILE "$constantArgs -eaa 1 -mb true -im output_eaa_1_mb_1 \"$sceneFile\"\n"; print CMDFILE "$constantArgs -eaa 2 -mb true -im output_eaa_2_mb_1 \"$sceneFile\"\n"; print CMDFILE "$constantArgs -eaa 3 -mb true -im output_eaa_3_mb_1 \"$sceneFile\""; close( CMDFILE ); }; # Get the arguments my $sceneFile = $ARGV[0]; my $frameNumber = $ARGV[1]; my $outputPath = $ARGV[2]; # Create the command script my $commandScript = "c:/Deadline/temp/commandScript.txt"; WriteCommandScript( $commandScript, $sceneFile, $frameNumber, $outputPath ); my $frameCount = CountFileLines($commandScript); # Write out the deadline submission files my ( $submitInfo, $jobInfo ); $submitInfo->{Plugin} = "CommandScript"; $submitInfo->{ForceReloadPlugin} = "false"; $submitInfo->{Frames} = "1-$frameCount"; $submitInfo->{Priority} = 50; $submitInfo->{Pool} = "testing"; $submitInfo->{Name} = "Maya Command Script Example"; $submitInfo->{PoolMachinesOnly} = "false"; $submitInfo->{OutputDirectory0} = $outputPath; $submitInfo->{ChunkSize} = 1; $submitInfo->{MachineLimit} = 0; $jobInfo->{StartupDirectory} = "c:/Deadline/temp"; WriteKeyFile( "c:/Deadline/temp/command_submit_info.txt", $submitInfo ); WriteKeyFile( "c:/Deadline/temp/command_job_info.txt", $jobInfo ); # Submit the job to Deadline system( "c:/Deadline/bin/DeadlineCommand.exe c:/Deadline/temp/command_submit_info.txt c:/Deadline/temp/command_job_info.txt \"" . $commandScript . "\"" );