Python Reference Guide
 
Loading...
Searching...
No Matches
BasicOperations\ImportWithNamespace.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 specify namespace of importation for Load/Merge of
8# native MB file or for FBX file generated from a FBX plugin
9#
10# Topic: FBApplication, FBFbxOptions
11#
12
13from pyfbsdk import *
14import os
15import os.path
16
17app = FBApplication()
18sys = FBSystem()
19
20#Utility function to get the name of a file without extension
21def getFileName(f):
22 d, filename = os.path.split(f)
23 if filename:
24 return os.path.splitext(filename)[0]
25 else:
26 return "unknown"
27
28# some constants for better clarity
29NO_LOAD_UI_DIALOG = False
30APPEND = False
31MERGE = True
32OPTIONS_FOR_LOAD = True
33
34
37nativeFile = os.path.abspath( os.path.join( sys.ApplicationPath, r"..\system\primitives\Cube.fbx"))
38print("Source File Path", nativeFile)
39
40# set the namespace of importation to the name of the scene
41options = FBFbxOptions(OPTIONS_FOR_LOAD)
42options.NamespaceList = getFileName(nativeFile)+ "_open"
43
44# Open a file with a custom namespace appended to all objects
45app.FileOpen( nativeFile, NO_LOAD_UI_DIALOG, options )
46
47# Append the same files with the same namespace appended. The renaming mecanims
48# will rename the namespace instead of the objects.
49options.NamespaceList = getFileName(nativeFile)+ "_append"
50app.FileAppend( nativeFile, NO_LOAD_UI_DIALOG, options )
51
52# We want to merge so change the FBElementAction of all options.
53options.NamespaceList = getFileName(nativeFile)+ "_open"
54options.SetAll(FBElementAction.kFBElementActionMerge, True)
55
56# Merge with the objects loaded with the FileOpen
57app.FileMerge( nativeFile, NO_LOAD_UI_DIALOG, options )
58
FBApplication is used mainly to manage files.
Definition: pyfbsdk_generated.h:801
Customize file loading and saving.
Definition: pyfbsdk_generated.h:7400
Provides access to the underlying system, and the MotionBuilder scene.
Definition: pyfbsdk_generated.h:18771