Tasks/ClearKeysOnSelectedModels.py

Tasks/ClearKeysOnSelectedModels.py
1 # Copyright 2009 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 # Topic: FBAnimationNode, FBFCurve
7 #
8 
9 
10 from pyfbsdk import FBModelList, FBGetSelectedModels
11 
12 def ClearAnim( pNode ):
13 
14  # The FCurve property will not be null on a terminal node.
15  # i.e. the 'Lcl Translation' node will not have any animation on it
16  # directly... only the sub-nodes 'X', 'Y' or 'Z' may have animation.
17  if pNode.FCurve:
18 
19  # Ah! there is a FCurve! Let's remove all the keys.
20  pNode.FCurve.EditClear()
21  else:
22  # Then we are dealing with a parent node. Let's look at it
23  # children nodes.
24  for lNode in pNode.Nodes:
25  # Recursively call ourselves to deal with sub-nodes.
26  ClearAnim( lNode )
27 
28  # Cleanup
29  del( lNode )
30 
31 
32 # Create an empty FBModelList object.
33 lModels = FBModelList()
34 
35 # Obtain the list of selected models.
36 FBGetSelectedModels( lModels )
37 
38 # Clear the animation for all the models selected.
39 for lModel in lModels:
40  ClearAnim( lModel.AnimationNode )
41 
42  # Cleanup.
43  del( lModel )
44 
45 # Cleanup of local objects.
46 del( lModels, ClearAnim )
47 
48 # Cleanup of imported modules.
49 del( FBModelList, FBGetSelectedModels )