Tasks/SaveSelected.py
 
 
 
Tasks/SaveSelected.py
# Copyright 2009 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.
#
# Topic: FBApplication.FileSave
#

from pyfbsdk import *
import os
import tempfile

# Create a cube
lCube = FBModelCube( 'MyCubeWillNotBeSaved' )
lCube.Show = True

# Create and select a plane
lPlane = FBModelPlane( 'MyPlaneWillBeSaved' )
lPlane.Show = True
lPlane.Selected = True

lOptions = FBFbxOptions(False)

# Save only the selected models, in ASCII format so we can have a look at the file.
lOptions.SaveSelectedModelsOnly = True
lOptions.UseASCIIFormat = True

# Not saving system information; only focus on the selected models.
lOptions.BaseCameras = False
lOptions.CameraSwitcherSettings = False
lOptions.CurrentCameraSettings = False
lOptions.GlobalLightingSettings = False
lOptions.TransportSettings = False

# Save the selected models to file.
lFilePath = os.path.join( tempfile.gettempdir(), "SaveSelected.fbx" )

if FBApplication().FileSave(lFilePath, lOptions):
    print "File successfully saved to %s" % lFilePath
else:
    print "Failed to save file: %s" % lFilePath