# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement 
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
#
# Topic: FBTake, FBSystem.CurrentTake, 
#
from pyfbsdk import FBSystem

# Get the name of the current take, to look it up in the list
# of system takes. Names are unique.
lSystem = FBSystem()
lCurrentTakeName = lSystem.CurrentTake.Name

# Look in the list until we find the index of the current take.
for lTakeIdx in range( len( lSystem.Scene.Takes )):
    if lSystem.Scene.Takes[lTakeIdx].Name == lCurrentTakeName:
        break;

# Decrement the index to point to the next take.
# Here we take advantage of Python's subscripting access
# where -1 points to the last object in the list, which is
# where we want to be if the current take is the first in
# the list.
lTakeIdx = lTakeIdx - 1

# Set the current take using our new index.
lSystem.CurrentTake = lSystem.Scene.Takes[lTakeIdx]

# Cleanup of local variables.
del( lSystem, lCurrentTakeName, lTakeIdx )

# Cleanup of imported modules.
del( FBSystem )