# 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.
#
# Script description:
# Shows how to create and modify FBFbxOptions to customize the Load/save process
#
# Topic: FBApplication, FBFbxOptions
#

from pyfbsdk import *

import os.path

SOURCE_SCENE_PATH = "multiple_elements_scene.fbx"
SAVE_SCENE_PATH = "single_elements_scene.fbx"
NO_LOAD_UI_DIALOG = False
OPTION_USED_FOR_LOADING = True
OPTION_USED_FOR_SAVING = False

app = FBApplication()

def CreateDummyScene():
    # Create a scene containing different types of elements and save it
    cube = FBModelCube("cube")
    character = FBCharacter("character")
    actor = FBActor("actor")
    camera = FBCamera("camera")

    app.FileSave(SOURCE_SCENE_PATH)
    app.FileNew()


#CreateDummyScene()

# Set a few options to Load a scene

# To init the option for a load/merge: pass True as first param
options = FBFbxOptions(OPTION_USED_FOR_LOADING)

# Set loading options. Options corresponds to the UI shown in a File -> Open/Merge

# Do not load character
options.Characters = FBElementAction.kFBElementActionDiscard

# Do not load Camera animation
options.CameraAnimation = False

# Load the file
app.FileOpen(SOURCE_SCENE_PATH, NO_LOAD_UI_DIALOG, options)

# Set options to save a scene
# Initialize options
options = FBFbxOptions(OPTION_USED_FOR_SAVING)

# Tell that by default we won't save anything
options.SetAll(FBElementAction.kFBElementActionDiscard, False)

# Except for the actor and its animation
options.Actor = FBElementAction.kFBElementActionSave
options.ActorAnimation = True

# Save the scene in ascci format
options.UseASCIIFormat = True

app.FileSave(SAVE_SCENE_PATH, options)