Samples/Utilities/SetPropertyStaticIfPossibleOption.py

# Copyright 2011 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.
# 
# This script demonstrate the usage of SetPropertyStaticIfPossible flag of FBFbxOptions, Set
# SetPropertyStaticIfPossible to False if want to keep properties' animated flag even when they
# are not really animated(no keyframe data) while retrieving/storing.
# 
# Topic: FBFbxOptions.SetPropertyStaticIfPossible
#
from pyfbsdk import FBApplication, FBFilePopup, FBFilePopupStyle, FBFbxOptions
import os

lApp = FBApplication()
lApp.FileNew()

# File Popup to select file to load
lFp = FBFilePopup()
lFp.Caption = "Select the fbx file:"
lFp.Style = FBFilePopupStyle.kFBFilePopupOpen
lFp.Filter = "*.fbx"

# File load options
lOptions = FBFbxOptions(True)
lOptions.ShowOptionsDialog = True

# Set False will disable the SetPropertyStaticIfPossible optimization
# Then set the retrieved properties with animated flag but without keyframe data to animated
# Set True will get these propertise to not animated when retrieved
lOptions.SetPropertyStaticIfPossible = False

lFbxFilePath = ""
if (lFp.Execute()):
    lFbxFilePath = os.path.join(lFp.Path,lFp.FileName)
    # Load file using file load options
    lApp.FileOpen(lFbxFilePath, True,lOptions)
   
   
# File Save options
lOptions = FBFbxOptions(False)
lOptions.ShowOptionsDialog = True

# Set False will disable the SetPropertyStaticIfPossible optimization
# Then set the storing properties with animated flag but without keyframe data to animated
# Set True will get these propertise to not animated when storing
lOptions.SetPropertyStaticIfPossible = False

# Save file using file save options
#lApp.FileSave(lFbxFilePath,lOptions)
 
# Cleanup
del( lFbxFilePath, lOptions, lFp, lApp )
del( FBApplication, FBFilePopup, FBFilePopupStyle, FBFbxOptions )