Tasks/TimeCodeKeying.py

Tasks/TimeCodeKeying.py
1 # Copyright 2011 Autodesk, Inc. All rights reserved.
2 # Use of this software is subject to the terms of the Autodesk license agreement
3 # provided at the time of installation or download, or which otherwise accompanies
4 # this software in either electronic or hard copy form.
5 #
6 # Script description:
7 # Create multiple FBTimeCode keys on a custom property on a cube.
8 #
9 # Topic: FBTimeCode, FBTake, FBPlayerControl
10 #
11 from pyfbsdk import *
12 
13 #Init
14 Player = FBPlayerControl()
15 Scene = FBSystem().Scene
16 System = FBSystem()
17 
18 ##Create a cube
19 cube = FBModelCube("Cube")
20 TCProp = cube.PropertyCreate( 'TimeCode_2997_Drop', FBPropertyType.kFBPT_TimeCode, 'TimeCode', True, True, None )
21 TCProp.SetAnimated(True)
22 
23 ##Property Init
24 cube.Show = True
25 cube.Visibility = True
26 cube.Selected = True
27 tc = FBTimeCode(FBTimeCode.NTSC_DROP)
28 
29 ##Add a key at time 0
30 Player.Goto(FBTime(0,0,0,0))
31 tc.SetTimeCode(0,0,0,1.0)
32 TCProp.Data = tc
33 TCProp.Key()
34 
35 ##Set another value at time 10
36 Player.Goto(FBTime(0,0,0,10))
37 tc.SetTimeCode(0,0,0,10.0)
38 TCProp.Data = tc
39 TCProp.Key()
40 
41 ##Set another value at time 20 but without moving Scene time
42 tc.SetTimeCode(0,0,0,20.0)
43 TCProp.Data = tc
44 TCProp.KeyAt(FBTime(0,0,0,20))
45 
46 ## timecode print frame at time 5
47 Player.Goto(FBTime(0,0,0,5))
48 tc = TCProp.Data
49 print "Frame %f" % tc.Frame