# 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;

# Increment the index to point to the next take.
lTakeIdx = lTakeIdx + 1

# Wrap around the end if the current take is the last.
if lTakeIdx == len( lSystem.Scene.Takes ): lTakeIdx = 0

# 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 )