Tasks/SaveSelected.py

Tasks/SaveSelected.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: FBApplication.FileSave
7 #
8 
9 from pyfbsdk import *
10 import os
11 import tempfile
12 
13 # Create a cube
14 lCube = FBModelCube( 'MyCubeWillNotBeSaved' )
15 lCube.Show = True
16 
17 # Create and select a plane
18 lPlane = FBModelPlane( 'MyPlaneWillBeSaved' )
19 lPlane.Show = True
20 lPlane.Selected = True
21 
22 lOptions = FBFbxOptions(False)
23 
24 # Save only the selected models, in ASCII format so we can have a look at the file.
25 lOptions.SaveSelectedModelsOnly = True
26 lOptions.UseASCIIFormat = True
27 
28 # Not saving system information; only focus on the selected models.
29 lOptions.BaseCameras = False
30 lOptions.CameraSwitcherSettings = False
31 lOptions.CurrentCameraSettings = False
32 lOptions.GlobalLightingSettings = False
33 lOptions.TransportSettings = False
34 
35 # Save the selected models to file.
36 lFilePath = os.path.join( tempfile.gettempdir(), "SaveSelected.fbx" )
37 
38 if FBApplication().FileSave(lFilePath, lOptions):
39  print "File successfully saved to %s" % lFilePath
40 else:
41  print "Failed to save file: %s" % lFilePath