# Copyright 2010 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. ######################################## # By: Kristine Middlemiss, ADN, 2010 ######################################## # Script description: # Create Custom 'Local' Keying Group. # This script creates a cube and adds translation, rotation and scaling properties of the # cube into a custom keying group, when you key the cube all three properties are Keyed, # (the default keying of a cube is only translation and rotation). In addition, after those # three properties are keyed on the cube, we remove the translation property for our custom # keying group, and test with keying that only the two remaining properties are set. Briefly # showes you how to remove all properties from you custom property group and deleting the # your custom key group. #Topic: FBKeyingGroup, FBKeyingGroupType, FBKeyingGroup.AddProperty, FBKeyingGroup.SetActive, FBKeyingGroup.SetEnabled, FBKeyingGroup.GetPropertyCount, FBKeyingGroup.FindPropertyIndex, FBKeyingGroup.GetCumulativePropertyCount, FBKeyingGroup.RemoveProperty, FBKeyingGroup.RemoveAllProperties, FBKeyingGroup.FBDelete from pyfbsdk import * ## Scene Setup ## # Get to the handle to the model lCube = FBModelCube("Cube") lCube.Show = True # Use the screen name to set the translation vector ltran = lCube.PropertyList.Find ( 'Translation (Lcl)' )#.Data = FBVector3d( -10, 5, 20 ) lrot = lCube.PropertyList.Find ( 'Rotation (Lcl)' ) lsca = lCube.PropertyList.Find ( 'Scaling (Lcl)' ) #Create Local Custom Key Group localKeyGroup = FBKeyingGroup("KrisLocalKeyGroup", FBKeyingGroupType.kFBKeyingGroupLocal) #Get Property Count print "Property Count Before Added Properties: %d \n" % localKeyGroup.GetPropertyCount () #Add Properties to Custom Key Group localKeyGroup.AddProperty(ltran) localKeyGroup.AddProperty(lrot) localKeyGroup.AddProperty(lsca) #Get Property Count print "Property Count After Added Properties: %d \n"% localKeyGroup.GetPropertyCount () # SetActive, activate the keying group. localKeyGroup.SetActive (True) # SetEnabled, will make available the keying group in keying group list of the key control UI. localKeyGroup.SetEnabled (True) #Getting the CumulativePropertyCount print localKeyGroup.GetCumulativePropertyCount () #Testing New Custom Keying Group, to make sure it included Scale lPlayer = FBPlayerControl() ltran.Data = FBVector3d( 0, 0, 0 ) lrot.Data = FBVector3d( 0, 45, 0 ) lsca.Data = FBVector3d( 5, 5, 5 ) lPlayer.Key() lPlayer.Goto(FBTime(0,0,0,20)) ltran.Data = FBVector3d( -80, 0, 00 ) lrot.Data = FBVector3d( 0, 45, 0 ) lsca.Data = FBVector3d( 1, 1, 1 ) lPlayer.Key() # Remove Translation Property From the Key Group localKeyGroup.RemoveProperty (ltran) # Test that it does not Key the Translation lPlayer.Goto(FBTime(0,0,0,40)) ltran.Data = FBVector3d( 80, 0, 00 ) lrot.Data = FBVector3d( 0,0, 0 ) lsca.Data = FBVector3d( 5, 5, 5 ) lPlayer.Key() #Working with additional Functions: # Any property not in our custom keying group returns a value of -1, you can test with ltran # The properties index changes when items are added and removed, not hard coded. print "FindPropertyIndex", localKeyGroup.FindPropertyIndex (lrot) print "FindPropertyIndex", localKeyGroup.FindPropertyIndex (lsca) # GetCumulativePropertyCount Same as GetSubKeyingGroupCount but recursive in child keying group. print localKeyGroup.GetCumulativePropertyCount () #Empty KeyGroup, commented out so you can verify the above works. #localKeyGroup.RemoveAllProperties () #Delete the KeyGroup, commented out so you can verify the above works. #localKeyGroup.FBDelete()