# 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 specify namespace of importation for Load/Merge of # native MB file or for FBX file generated from a FBX plugin # # Topic: FBApplication, FBFbxOptions # from pyfbsdk import * import os import os.path app = FBApplication() sys = FBSystem() #Utility function to get the name of a file without extension def getFileName(f): d, filename = os.path.split(f) if filename: return os.path.splitext(filename)[0] else: return "unknown" # some constants for better clarity NO_LOAD_UI_DIALOG = False APPEND = False MERGE = True OPTIONS_FOR_LOAD = True #### These tests are design to test the load/Merge #### of Native MB scene. It shows how to specify a namespace #### of importation for all objects in the scene. nativeFile = os.path.abspath( os.path.join( sys.ApplicationPath, r"..\system\primitives\Cube.fbx")) print "Source File Path", nativeFile # set the namespace of importation to the name of the scene options = FBFbxOptions(OPTIONS_FOR_LOAD) options.NamespaceList = getFileName(nativeFile)+ "_open" # Open a file with a custom namespace appended to all objects app.FileOpen( nativeFile, NO_LOAD_UI_DIALOG, options ) # Append the same files with the same namespace appended. The renaming mecanims # will rename the namespace instead of the objects. options.NamespaceList = getFileName(nativeFile)+ "_append" app.FileAppend( nativeFile, NO_LOAD_UI_DIALOG, options ) # We want to merge so change the FBElementAction of all options. options.NamespaceList = getFileName(nativeFile)+ "_open" options.SetAll(FBElementAction.kFBElementActionMerge, True) # Merge with the objects loaded with the FileOpen app.FileMerge( nativeFile, NO_LOAD_UI_DIALOG, options )