ChangeRenderOutputPaths Script

From The Foundry MODO SDK wiki
Revision as of 23:06, 1 April 2012 by Jangell (Talk | contribs) (Created page with "This script loops through all render output items and changes their paths. The original filename is appended to the new path. Be sure to include the trailing slash at the end ...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This script loops through all render output items and changes their paths. The original filename is appended to the new path. Be sure to include the trailing slash at the end of the new path.

@ChangeRenderOutputPaths.pl C:\New\Path\

The script loops through all items looking for render output items. For each one found, it grabs the original path, uses regular expressions to split out the filename, appends it to the new path, and updates the item’s channel.

  1. # perl
  2. # ChangeRenderOutputPaths.pl
  3. #  Joe Angell, Luxology LLC
  4. #  Copyright (c) 2008 Luxology, LLC. All Rights Reserved.
  5. #  Patents pending.
  6. #
  7. # Changes the output paths of all render output items
  8. #  in the scene
  9.  
  10. # Make sure we have our arguments
  11. if( $#ARGV + 1 != 1 ) {
  12.     lxout( "Usage: \@ChangeRenderOutputPaths.pl new/output/path/" );
  13.     lxout( "Changes all render output item paths to the provided path with the original filename." );
  14.     lxout( "The argument is the new path, which must include the trailing slash." );
  15.     die( "Missing required new path argument" );
  16. }
  17.  
  18. my $filenamePart;
  19.  
  20. # Get the item count
  21. my $n = lxq( "query sceneservice item.N ?" );
  22.  
  23. # Loop through the items in the scene, looking for output items
  24. for( $i=0; $i < $n; $i++ ) {
  25.     my $type = lxq( "query sceneservice item.type ? $i" );
  26.     if( $type eq "renderOutput" ) {
  27.         # Get the item ID
  28.         $itemID = lxq( "query sceneservice item.id ? $i" );
  29.         lxout( "Item ID: $itemID" );
  30.  
  31.         # Select the item
  32.         lx( "select.item $itemID" );
  33.  
  34.         # Get the original path
  35.         my $originalPath = lxq( "item.channel renderOutput\$filename ?" );
  36.  
  37.         # If the path is empty, skip it
  38.         if( !$originalPath ) {
  39.             next;
  40.         }
  41.  
  42.         # Split the path from the filename using regex
  43.         my @pathParts = split( /\/|\\/, $originalPath );
  44.         if( @pathParts == 0 ) {
  45.             # Nothing to split; path must consist of
  46.             #  just the filename
  47.             $filenamePart = $originalPath;
  48.         } else {
  49.             $filenamePart = $pathParts[ @pathParts - 1 ];
  50.         }
  51.  
  52.         # Combine the passed in path with the original filename
  53.         $newPath = $ARGV[0] . $filenamePart;
  54.  
  55.         lx( "item.channel renderOutput\$filename {$newPath}" );
  56.     }
  57. }

More Information