Tasks/TimeCodeKeying.py

# Copyright 2011 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.
#
# Script description:
# Create multiple FBTimeCode keys on a custom property on a cube.
#
# Topic: FBTimeCode, FBTake, FBPlayerControl
#
from pyfbsdk import *

#Init
Player = FBPlayerControl()
Scene = FBSystem().Scene
System = FBSystem()

##Create a cube
cube = FBModelCube("Cube")
TCProp = cube.PropertyCreate( 'TimeCode_2997_Drop', FBPropertyType.kFBPT_TimeCode, 'TimeCode', True, True, None )  
TCProp.SetAnimated(True)

##Property Init
cube.Show = True
cube.Visibility = True
cube.Selected = True
tc = FBTimeCode(FBTimeCode.NTSC_DROP)

##Add a key at time 0
Player.Goto(FBTime(0,0,0,0))
tc.SetTimeCode(0,0,0,1.0)
TCProp.Data = tc
TCProp.Key()

##Set another value at time 10
Player.Goto(FBTime(0,0,0,10))
tc.SetTimeCode(0,0,0,10.0)
TCProp.Data = tc
TCProp.Key()

##Set another value at time 20 but without moving Scene time
tc.SetTimeCode(0,0,0,20.0)
TCProp.Data = tc
TCProp.KeyAt(FBTime(0,0,0,20))

## timecode print frame at time 5
Player.Goto(FBTime(0,0,0,5))
tc = TCProp.Data
print "Frame %f" % tc.Frame