BasicOperations/FBFbxOptions.py

BasicOperations/FBFbxOptions.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 # Script description:
7 # Shows how to create and modify FBFbxOptions to customize the Load/save process
8 #
9 # Topic: FBApplication, FBFbxOptions
10 #
11 
12 from pyfbsdk import *
13 
14 import os.path
15 
16 SOURCE_SCENE_PATH = "multiple_elements_scene.fbx"
17 SAVE_SCENE_PATH = "single_elements_scene.fbx"
18 NO_LOAD_UI_DIALOG = False
19 OPTION_USED_FOR_LOADING = True
20 OPTION_USED_FOR_SAVING = False
21 
22 app = FBApplication()
23 
24 def CreateDummyScene():
25  # Create a scene containing different types of elements and save it
26  cube = FBModelCube("cube")
27  character = FBCharacter("character")
28  actor = FBActor("actor")
29  camera = FBCamera("camera")
30 
31  app.FileSave(SOURCE_SCENE_PATH)
32  app.FileNew()
33 
34 
35 CreateDummyScene()
36 
37 # Set a few options to Load a scene
38 
39 # To init the option for a load/merge: pass True as first param
40 options = FBFbxOptions(OPTION_USED_FOR_LOADING)
41 
42 # Set loading options. Options corresponds to the UI shown in a File -> Open/Merge
43 
44 # Do not load character
45 options.Characters = FBElementAction.kFBElementActionDiscard
46 
47 # Do not load Camera animation
48 options.CameraAnimation = False
49 
50 # Load the file
51 app.FileOpen(SOURCE_SCENE_PATH, NO_LOAD_UI_DIALOG, options)
52 
53 # Set options to save a scene
54 # Initialize options
55 options = FBFbxOptions(OPTION_USED_FOR_SAVING)
56 
57 # Tell that by default we won't save anything
58 options.SetAll(FBElementAction.kFBElementActionDiscard, False)
59 
60 # Except for the actor and its animation
61 options.Actors = FBElementAction.kFBElementActionSave
62 options.ActorAnimation = True
63 
64 # Save the scene in ascci format
65 options.UseASCIIFormat = True
66 
67 app.FileSave(SAVE_SCENE_PATH, options)
68 
69