1
2
3
4
5
6
7
8
9from pyfbsdk import FBSystem, FBApplication, FBFilePopup, FBFilePopupStyle, FBFbxOptions
10
11
12def getFileName(f):
13 import os
14 d, filename = os.path.split(f)
15 if filename:
16 return os.path.splitext(filename)[0]
17 else:
18 return "unknown"
19
20
23lFileName = lApplication.FBXFileName
24if lFileName == "":
26 FileDlg.Style = FBFilePopupStyle.kFBFilePopupSave
27 FileDlg.Caption = "The current filename is not valid."
28 FileDlg.FileName = "Untitled.fbx"
29 FileDlg.Filter = "*"
30 if FileDlg.Execute():
31 lFileName = FileDlg.FileName
32
33
34
35
36
37if lFileName.upper().endswith( '.FBX' ):
39 lOriginalTake = lSystem.CurrentTake
40
41
42 for lTake in lSystem.Scene.Takes:
43
44
45 lSystem.CurrentTake = lTake
46
47
48
49 lTakeFileName = "%s-%s.fbx" % ( getFileName(lFileName), lTake.Name )
50
51
52 print("Saving Take '%s' to file '%s'" % ( lTake.Name, lTakeFileName ))
53
54
55 lOptions.UseASCIIFormat = True
56
57
58
59
60 for index in range(lOptions.GetTakeCount()):
61 if lOptions.GetTakeName(index) == lTake.Name:
62 lOptions.SetTakeSelect(index, True)
63 else:
64 lOptions.SetTakeSelect(index, False)
65 lApplication.FileSave( lTakeFileName, lOptions )
66
67
68
69 lSystem.CurrentTake = lOriginalTake
70
71 del( lOriginalTake, lOptions )
72
73else:
74
75 print('File name does not end with ".fbx". Unable to proceed!')
76
77
78
79del( lSystem, lApplication, lFileName )
80
81
82del( FBSystem, FBApplication )
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