Difference between revisions of "ChangeRenderFrameRange Script"

From The Foundry MODO SDK wiki
Jump to: navigation, search
(More Information)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
This simple script changes the first frame, last frame and frame step of the first render item in the scene. This is a bit easier than calling three separate item.channel commands and making sure that the first render item is actually selected.
 
This simple script changes the first frame, last frame and frame step of the first render item in the scene. This is a bit easier than calling three separate item.channel commands and making sure that the first render item is actually selected.
  
{{TabbedArea
+
<tabber>
|Perl|
+
  Perl=@ChangeRenderFrameRange.pl first last <step>
  @ChangeRenderFrameRange.pl first last <step>
+
|-|
|Lua|
+
  LUA=@ChangeRenderFrameRange.lua first last <step>
  @ChangeRenderFrameRange.lua first last <step>
+
|-|
|Python|
+
  Python=@ChangeRenderFrameRange.py first last <step>
  @ChangeRenderFrameRange.py first last <step>
+
</tabber>
}}
+
  
 
The first and last frame arguments are required, while the frame step is optional. This sets the first frame to 1 and the last frame to 60.
 
The first and last frame arguments are required, while the frame step is optional. This sets the first frame to 1 and the last frame to 60.
  
{{TabbedArea
+
<tabber>
|Perl|
+
Perl=@ChangeRenderFrameRange.pl 1 60
@ChangeRenderFrameRange.pl 1 60
+
|-|
|Lua|
+
  LUA=@ChangeRenderFrameRange.lua 1 60
  @ChangeRenderFrameRange.lua 1 60
+
|-|
|Python|
+
  Python=@ChangeRenderFrameRange.py 1 60
  @ChangeRenderFrameRange.py 1 60
+
</tabber>
}}
+
  
 
This script could be simplified by directly selecting the render items with [[select.itemType]], but this extended version can be used as a framework for other scripts that operate on item types.
 
This script could be simplified by directly selecting the render items with [[select.itemType]], but this extended version can be used as a framework for other scripts that operate on item types.
  
{{TabbedArea
+
<tabber>
|Perl|
+
Perl=
 
<syntaxhighlight lang="perl" line>
 
<syntaxhighlight lang="perl" line>
 
# perl
 
# perl
Line 73: Line 71:
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
|Lua|
+
|-|
 +
LUA=
 
<syntaxhighlight lang="lua" line>
 
<syntaxhighlight lang="lua" line>
 
-- lua
 
-- lua
Line 87: Line 86:
 
-- Make sure we have our arguments
 
-- Make sure we have our arguments
 
if( (#arg != 1) && (#arg != 2) ) {
 
if( (#arg != 1) && (#arg != 2) ) {
     lxout( "Usage: \@ChangeRenderFrameRange.lua first last <step>" );
+
     lxout( "Usage: @ChangeRenderFrameRange.lua first last <step>" );
 
     lxout( "Changes the render frame range for the first render item in the scene." );
 
     lxout( "Changes the render frame range for the first render item in the scene." );
 
     lxout( "First and last frame are required; frame step is optional." );
 
     lxout( "First and last frame are required; frame step is optional." );
Line 122: Line 121:
 
end
 
end
 
</syntaxhighlight>
 
</syntaxhighlight>
|Python|
+
|-|
<syntaxhighlight lang="lua" line>
+
Python=
# lua
+
<syntaxhighlight lang="python" line>
 +
#python
 
#
 
#
 
# ChangeRenderFrameRange.py
 
# ChangeRenderFrameRange.py
Line 136: Line 136:
 
# Make sure we have our arguments
 
# Make sure we have our arguments
 
args = lx.args()
 
args = lx.args()
if (len(args) != 1) && (len(args) != 2):
+
if not (len(args) == 2 or len(args) == 3):
     lxout( "Usage: \@ChangeRenderFrameRange.lua first last <step>" )
+
     lx.out( "Usage: @ChangeRenderFrameRange.py first last <step>" )
     lxout( "Changes the render frame range for the first render item in the scene." )
+
     lx.out( "Changes the render frame range for the first render item in the scene." )
     lxout( "First and last frame are required; frame step is optional." )
+
     lx.out( "First and last frame are required; frame step is optional." )
 
     sys.exit( "LXe_INVALIDARG:Missing required first and last frame arguments" )
 
     sys.exit( "LXe_INVALIDARG:Missing required first and last frame arguments" )
}
 
  
 
# Get the item count
 
# Get the item count
Line 148: Line 147:
 
# Loop through the items in the scene, looking for output items
 
# Loop through the items in the scene, looking for output items
 
for i in range(n):
 
for i in range(n):
     type = lxq( "query sceneservice item.type ? " + i )
+
     itemtype = lx.eval( "query sceneservice item.type ? %s" % i )
     if type == "polyRender":
+
 
 +
     if itemtype == "polyRender":
 
         # Get the item ID
 
         # Get the item ID
         itemID = lxq( "query sceneservice item.id ? " + i )
+
         itemID = lx.eval( "query sceneservice item.id ?")
         # lxout( "Item ID:  ", itemID )
+
         # lx.out( "Item ID:  ", itemID )
  
 
         # Select the item
 
         # Select the item
Line 158: Line 158:
  
 
         # Set the first frame
 
         # Set the first frame
         lx.command( "item.channel", channel="polyRender$first", value=args[1] )
+
         lx.command( "item.channel", name="polyRender$first", value=args[0] )
  
 
         # Set the last frame
 
         # Set the last frame
         lx.command( "item.channel", channel="polyRender$last", value=args[1] )
+
         lx.command( "item.channel", name="polyRender$last", value=args[1] )
  
 
         if len(args) == 3:
 
         if len(args) == 3:
 
             # Set the frame step
 
             # Set the frame step
             lx.command( "item.channel", channel="polyRender$step", value=args[1] )
+
             lx.command( "item.channel", name="polyRender$step", value=args[2] )
+
        break;
+
 
</syntaxhighlight>
 
</syntaxhighlight>
}}
+
</tabber>
  
 
== More Information ==
 
== More Information ==

Latest revision as of 13:42, 7 July 2015

This simple script changes the first frame, last frame and frame step of the first render item in the scene. This is a bit easier than calling three separate item.channel commands and making sure that the first render item is actually selected.

@ChangeRenderFrameRange.pl first last <step>

@ChangeRenderFrameRange.lua first last <step>

@ChangeRenderFrameRange.py first last <step>

The first and last frame arguments are required, while the frame step is optional. This sets the first frame to 1 and the last frame to 60.

@ChangeRenderFrameRange.pl 1 60

@ChangeRenderFrameRange.lua 1 60

@ChangeRenderFrameRange.py 1 60

This script could be simplified by directly selecting the render items with Select.itemType, but this extended version can be used as a framework for other scripts that operate on item types.

  1. # perl
  2. #
  3. # ChangeRenderFrameRange.pl
  4. #  Joe Angell, Luxology LLC
  5. #  Copyright (c) 2008 Luxology, LLC. All Rights Reserved.
  6. #   Patents pending.
  7. #
  8. # Changes the render frame range for the first render item
  9. #  in the scene.
  10.  
  11. # Make sure we have our arguments
  12. if( ($#ARGV != 1) && ($#ARGV != 2) ) {
  13.     lxout( "Usage: \@ChangeRenderFrameRange.pl first last <step>" );
  14.     lxout( "Changes the render frame range for the first render item in the scene." );
  15.     lxout( "First and last frame are required; frame step is optional." );
  16.     die( "Missing required first and last frame arguments" );
  17. }
  18.  
  19. # Get the item count
  20. my $n = lxq( "query sceneservice item.N ?" );
  21.  
  22. # Loop through the items in the scene, looking for output items
  23. for( $i=0; $i < $n; $i++ ) {
  24.     my $type = lxq( "query sceneservice item.type ? $i" );
  25.     if( $type eq "polyRender" ) {
  26.         # Get the item ID
  27.         $itemID = lxq( "query sceneservice item.id ? $i" );
  28.         #lxout( "Item ID:  $itemID" );
  29.  
  30.         # Select the item
  31.         lx( "select.item $itemID" );
  32.  
  33.         # Set the first frame
  34.         lx( "item.channel polyRender\$first $ARGV[0]" );
  35.  
  36.         # Set the last frame
  37.         lx( "item.channel polyRender\$last $ARGV[1]" );
  38.  
  39.         if($#ARGV==3){
  40.             # Set the frame step
  41.             lx( "item.channel polyRender\$step $ARGV[2]" );
  42.         }
  43.  
  44.         break;
  45.     }
  46. }

  1. -- lua
  2. --
  3. -- ChangeRenderFrameRange.lua
  4. --  Joe Angell, Luxology LLC
  5. --  Copyright (c) 2008 Luxology, LLC. All Rights Reserved.
  6. --   Patents pending.
  7. --
  8. -- Changes the render frame range for the first render item
  9. --  in the scene.
  10.  
  11. -- Make sure we have our arguments
  12. if( (#arg != 1) && (#arg != 2) ) {
  13.     lxout( "Usage: @ChangeRenderFrameRange.lua first last <step>" );
  14.     lxout( "Changes the render frame range for the first render item in the scene." );
  15.     lxout( "First and last frame are required; frame step is optional." );
  16.     error( "Missing required first and last frame arguments" );
  17. }
  18.  
  19. -- Get the item count
  20. n = lxq( "query sceneservice item.N ?" );
  21.  
  22. -- Loop through the items in the scene, looking for output items
  23. for i=0,n do
  24.     type = lxq( "query sceneservice item.type ? "..i );
  25.     if type == "polyRender" then
  26.         -- Get the item ID
  27.         itemID = lxq( "query sceneservice item.id ? "..i );
  28.         -- lxout( "Item ID:  "..itemID );
  29.  
  30.         -- Select the item
  31.         lx( "select.item "..itemID );
  32.  
  33.         -- Set the first frame
  34.         lx( "item.channel polyRender$first "..arg[1] );
  35.  
  36.         -- Set the last frame
  37.         lx( "item.channel polyRender$last "..arg[2] );
  38.  
  39.         if #arg==3 then
  40.             -- Set the frame step
  41.             lx( "item.channel polyRender$step "..arg[3]" );
  42.         end
  43.  
  44.         break;
  45.     end
  46. end

  1. #python
  2. #
  3. # ChangeRenderFrameRange.py
  4. #  Joe Angell, Luxology LLC
  5. #  Copyright (c) 2008 Luxology, LLC. All Rights Reserved.
  6. #   Patents pending.
  7. #
  8. # Changes the render frame range for the first render item
  9. #  in the scene.
  10.  
  11. # Make sure we have our arguments
  12. args = lx.args()
  13. if not (len(args) == 2 or len(args) == 3):
  14.     lx.out( "Usage: @ChangeRenderFrameRange.py first last <step>" )
  15.     lx.out( "Changes the render frame range for the first render item in the scene." )
  16.     lx.out( "First and last frame are required; frame step is optional." )
  17.     sys.exit( "LXe_INVALIDARG:Missing required first and last frame arguments" )
  18.  
  19. # Get the item count
  20. n = lx.eval1( "query sceneservice item.N ?" )
  21.  
  22. # Loop through the items in the scene, looking for output items
  23. for i in range(n):
  24.     itemtype = lx.eval( "query sceneservice item.type ? %s" % i )
  25.  
  26.     if itemtype == "polyRender":
  27.         # Get the item ID
  28.         itemID = lx.eval( "query sceneservice item.id ?")
  29.         # lx.out( "Item ID:  ", itemID )
  30.  
  31.         # Select the item
  32.         lx.command( "select.item", item=itemID )
  33.  
  34.         # Set the first frame
  35.         lx.command( "item.channel", name="polyRender$first", value=args[0] )
  36.  
  37.         # Set the last frame
  38.         lx.command( "item.channel", name="polyRender$last", value=args[1] )
  39.  
  40.         if len(args) == 3:
  41.             # Set the frame step
  42.             lx.command( "item.channel", name="polyRender$step", value=args[2] )

More Information