ChangeRenderFrameRange Script

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.

Perl

@ChangeRenderFrameRange.pl first last <step>

Lua

@ChangeRenderFrameRange.lua first last <step>

Python

@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.

Perl

@ChangeRenderFrameRange.pl 1 60

Lua

@ChangeRenderFrameRange.lua 1 60

Python

@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.

Perl

# perl
#
# ChangeRenderFrameRange.pl
#  Joe Angell, Luxology LLC
#  Copyright (c) 2008 Luxology, LLC. All Rights Reserved.
#   Patents pending.
#
# Changes the render frame range for the first render item
#  in the scene.

# Make sure we have our arguments
if( ($#ARGV != 1) && ($#ARGV != 2) ) {
    lxout( "Usage: \@ChangeRenderFrameRange.pl first last <step>" );
    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." );
    die( "Missing required first and last frame arguments" );
}

# Get the item count
my $n = lxq( "query sceneservice item.N ?" );

# Loop through the items in the scene, looking for output items
for( $i=0; $i < $n; $i++ ) {
    my $type = lxq( "query sceneservice item.type ? $i" );
    if( $type eq "polyRender" ) {
        # Get the item ID
        $itemID = lxq( "query sceneservice item.id ? $i" );
        #lxout( "Item ID:  $itemID" );

        # Select the item
        lx( "select.item $itemID" );

        # Set the first frame
        lx( "item.channel polyRender\$first $ARGV[0]" );

        # Set the last frame
        lx( "item.channel polyRender\$last $ARGV[1]" );

        if($#ARGV==3){
            # Set the frame step
            lx( "item.channel polyRender\$step $ARGV[2]" );
        }

        break;
    }
}

Lua

-- lua
--
-- ChangeRenderFrameRange.lua
--  Joe Angell, Luxology LLC
--  Copyright (c) 2008 Luxology, LLC. All Rights Reserved.
--   Patents pending.
--
-- Changes the render frame range for the first render item
--  in the scene.

-- Make sure we have our arguments
if( (#arg != 1) && (#arg != 2) ) {
    lxout( "Usage: @ChangeRenderFrameRange.lua first last <step>" );
    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." );
    error( "Missing required first and last frame arguments" );
}

-- Get the item count
n = lxq( "query sceneservice item.N ?" );

-- Loop through the items in the scene, looking for output items
for i=0,n do
    type = lxq( "query sceneservice item.type ? "..i );
    if type == "polyRender" then
        -- Get the item ID
        itemID = lxq( "query sceneservice item.id ? "..i );
        -- lxout( "Item ID:  "..itemID );

        -- Select the item
        lx( "select.item "..itemID );

        -- Set the first frame
        lx( "item.channel polyRender$first "..arg[1] );

        -- Set the last frame
        lx( "item.channel polyRender$last "..arg[2] );

        if #arg==3 then
            -- Set the frame step
            lx( "item.channel polyRender$step "..arg[3]" );
        end

        break;
    end
end

Python

#python
#
# ChangeRenderFrameRange.py
#  Joe Angell, Luxology LLC
#  Copyright (c) 2008 Luxology, LLC. All Rights Reserved.
#   Patents pending.
#
# Changes the render frame range for the first render item
#  in the scene.

# Make sure we have our arguments
args = lx.args()
if not (len(args) == 2 or len(args) == 3):
    lx.out( "Usage: @ChangeRenderFrameRange.py first last <step>" )
    lx.out( "Changes the render frame range for the first render item in the scene." )
    lx.out( "First and last frame are required; frame step is optional." )
    sys.exit( "LXe_INVALIDARG:Missing required first and last frame arguments" )

# Get the item count
n = lx.eval1( "query sceneservice item.N ?" )

# Loop through the items in the scene, looking for output items
for i in range(n):
    itemtype = lx.eval( "query sceneservice item.type ? %s" % i )

    if itemtype == "polyRender":
        # Get the item ID
        itemID = lx.eval( "query sceneservice item.id ?")
        # lx.out( "Item ID:  ", itemID )

        # Select the item
        lx.command( "select.item", item=itemID )

        # Set the first frame
        lx.command( "item.channel", name="polyRender$first", value=args[0] )

        # Set the last frame
        lx.command( "item.channel", name="polyRender$last", value=args[1] )

        if len(args) == 3:
            # Set the frame step
            lx.command( "item.channel", name="polyRender$step", value=args[2] )