BasicOperations/PlotClearProperties.py

BasicOperations/PlotClearProperties.py
1 # Copyright 2012 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 # Shows how plotting or clearing of locked properties can be used.
8 #
9 
10 from pyfbsdk import *
11 
12 # Get a new scene.
13 FBApplication().FileNew()
14 
15 # Create a simple cube on which properties will be manipulated.
16 lCube = FBModelCube( "Cube" )
17 lCube.Show = True
18 
19 # Get the translation property which we will manipulate and animate.
20 lTranslation = lCube.PropertyList.Find( 'Lcl Translation' )
21 
22 # Add a couple of keys.
23 lTime = FBTime()
24 lPlayerControl = FBPlayerControl()
25 
26 lTime.SetFrame( 0 )
27 lPlayerControl.Goto( lTime )
28 lTranslation.Data = FBVector3d( 2 , 3 , 4 )
29 lTranslation.Key()
30 
31 lTime.SetFrame( 30 )
32 lPlayerControl.Goto( lTime )
33 lTranslation.Data = FBVector3d( 5 , 9 , 2 )
34 lTranslation.Key()
35 
36 lTime.SetFrame( 60 )
37 lPlayerControl.Goto( lTime )
38 lTranslation.Data = FBVector3d( 9 , 5 , 5 )
39 lTranslation.Key()
40 
41 # Lock a channel.
42 lTranslation.SetMemberLocked( 1 , True )
43 
44 
45 # Display the number of keys.
46 print 'Number of keys on each channel before everything : '
47 lIndex = 0
48 for lNode in lTranslation.GetAnimationNode().Nodes:
49  print ' Node #' + str(lIndex) + ' : ' + str( lNode.KeyCount )
50  lIndex = lIndex + 1
51 print 'All keys are there.'
52 print ''
53 
54 # Try to plot all but what is locked.
55 lCube.Selected = True
56 lOptions = FBPlotOptions()
57 lOptions.PlotLockedProperties = False
58 lSystem = FBSystem()
59 lSystem.CurrentTake.PlotTakeOnSelected( lOptions )
60 
61 # Display the number of keys.
62 print 'Number of keys on each channel after ploting #1 : '
63 lIndex = 0
64 for lNode in lTranslation.GetAnimationNode().Nodes:
65  print ' Node #' + str(lIndex) + ' : ' + str( lNode.KeyCount )
66  lIndex = lIndex + 1
67 print 'Nothing is plotted on locked channel.'
68 print ''
69 
70 # Try to plot all.
71 lCube.Selected = True
72 lOptions = FBPlotOptions()
73 lOptions.PlotLockedProperties = True
74 lSystem = FBSystem()
75 lSystem.CurrentTake.PlotTakeOnSelected( lOptions )
76 
77 # Display the number of keys.
78 print 'Number of keys on each channel after ploting #2 : '
79 lIndex = 0
80 for lNode in lTranslation.GetAnimationNode().Nodes:
81  print ' Node #' + str(lIndex) + ' : ' + str( lNode.KeyCount )
82  lIndex = lIndex + 1
83 print 'Keys on locked channel are also plotted.'
84 print ''
85 
86 # Try to clear all animations.
87 lSystem = FBSystem()
88 lSystem.CurrentTake.ClearAllProperties( False )
89 
90 # Display the number of keys.
91 print 'Number of keys on each channel after clearing #1 : '
92 lIndex = 0
93 for lNode in lTranslation.GetAnimationNode().Nodes:
94  print ' Node #' + str(lIndex) + ' : ' + str( lNode.KeyCount )
95  lIndex = lIndex + 1
96 print 'Keys on locked channel are not cleared.'
97 print ''
98 
99 # Try to clear all animations even locked ones.
100 lSystem.CurrentTake.ClearAllProperties( False , True )
101 
102 # Display the number of keys.
103 print 'Number of keys on each channel after clearing #2 : '
104 lIndex = 0
105 for lNode in lTranslation.GetAnimationNode().Nodes:
106  print ' Node #' + str(lIndex) + ' : ' + str( lNode.KeyCount )
107  lIndex = lIndex + 1
108 print 'All keys have been cleared.'
109 print ''