# 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: FBFbxManager
#

from pyfbsdk import FBFbxManager

# Create our manager. The saving process is done in 3 steps.
# 1- Start the save with the call to 'SaveBegin()'. This will populate
#    the list of takes in 'Takes'
# 2- Set the desired options and the call 'Save().
# 3- Finish the process by calling 'SaveEnd()'.
# 
# Do remember that each of the 3 'Save*' methods will return a boolean
# indicating success of failure. Method 'SaveEnd()' should always be called
# even if one of the previous call failed.

lMgr = FBFbxManager()

# For now use a hard-code filename... Could have used the FBFilePopup.
# If this call fails, there is no point in continuing... We just skip
# everything and call 'SaveEnd()'.
if lMgr.SaveBegin( r'C:\SaveSelected.fbx' ):

    # Save only selected files, in ASCII format so we can have a look
    # at the file.
    lMgr.UseASCIIFormat = True
    lMgr.Selected = True

    # There is no point in saving all the system information...
    # We just want the selected models.
    lMgr.BaseCameras = False
    lMgr.CameraSwitcherSettings = False
    lMgr.CurrentCameraSettings = False
    lMgr.GlobalLightingSettings = False
    lMgr.TransportSettings = False

    # Now do the actual save.    
    if not lMgr.Save():
        print 'Problem saving the file: Save()'

else:
    print 'Problem saving the file: SaveBegin()'

if not lMgr.SaveEnd():
    print 'Problem saving the file: SaveEnd()'