BasicOperations/PlotClearProperties.py

# Copyright 2012 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:
# Shows how plotting or clearing of locked properties can be used.
#

from pyfbsdk import *

# Get a new scene.
FBApplication().FileNew()

# Create a simple cube on which properties will be manipulated.
lCube = FBModelCube( "Cube" )
lCube.Show = True

# Get the translation property which we will manipulate and animate.
lTranslation = lCube.PropertyList.Find( 'Lcl Translation' )

# Add a couple of keys.
lTime = FBTime()
lPlayerControl = FBPlayerControl()

lTime.SetFrame( 0 )
lPlayerControl.Goto( lTime )
lTranslation.Data = FBVector3d( 2 , 3 , 4 )
lTranslation.Key()

lTime.SetFrame( 30 )
lPlayerControl.Goto( lTime )
lTranslation.Data = FBVector3d( 5 , 9 , 2 )
lTranslation.Key()

lTime.SetFrame( 60 )
lPlayerControl.Goto( lTime )
lTranslation.Data = FBVector3d( 9 , 5 , 5 )
lTranslation.Key()

# Lock a channel.
lTranslation.SetMemberLocked( 1 , True )


# Display the number of keys.
print 'Number of keys on each channel before everything : '
lIndex = 0
for lNode in lTranslation.GetAnimationNode().Nodes:
    print '    Node #' + str(lIndex) + ' : ' + str( lNode.KeyCount )
    lIndex = lIndex + 1
print 'All keys are there.'
print ''
    
# Try to plot all but what is locked.
lCube.Selected = True
lOptions = FBPlotOptions()
lOptions.PlotLockedProperties = False
lSystem = FBSystem()
lSystem.CurrentTake.PlotTakeOnSelected( lOptions )

# Display the number of keys.
print 'Number of keys on each channel after ploting #1 : '
lIndex = 0
for lNode in lTranslation.GetAnimationNode().Nodes:
    print '    Node #' + str(lIndex) + ' : ' + str( lNode.KeyCount )
    lIndex = lIndex + 1
print 'Nothing is plotted on locked channel.'
print ''
    
# Try to plot all.
lCube.Selected = True
lOptions = FBPlotOptions()
lOptions.PlotLockedProperties = True
lSystem = FBSystem()
lSystem.CurrentTake.PlotTakeOnSelected( lOptions )

# Display the number of keys.
print 'Number of keys on each channel after ploting #2 : '
lIndex = 0
for lNode in lTranslation.GetAnimationNode().Nodes:
    print '    Node #' + str(lIndex) + ' : ' + str( lNode.KeyCount )
    lIndex = lIndex + 1
print 'Keys on locked channel are also plotted.'
print ''
    
# Try to clear all animations.
lSystem = FBSystem()
lSystem.CurrentTake.ClearAllProperties( False )

# Display the number of keys.
print 'Number of keys on each channel after clearing #1 : '
lIndex = 0
for lNode in lTranslation.GetAnimationNode().Nodes:
    print '    Node #' + str(lIndex) + ' : ' + str( lNode.KeyCount )
    lIndex = lIndex + 1
print 'Keys on locked channel are not cleared.'
print ''
    
# Try to clear all animations even locked ones.
lSystem.CurrentTake.ClearAllProperties( False , True )

# Display the number of keys.
print 'Number of keys on each channel after clearing #2 : '
lIndex = 0
for lNode in lTranslation.GetAnimationNode().Nodes:
    print '    Node #' + str(lIndex) + ' : ' + str( lNode.KeyCount )
    lIndex = lIndex + 1
print 'All keys have been cleared.'
print ''