使用Python FBX SDK将* .obj转换为* .fbx

时间:2015-12-07 11:27:31

标签: python fbx

我尝试为Autodesk Python FBX SDK找到一些文档,但它似乎只适用于C ++(http://help.autodesk.com/view/FBX/2015/ENU/?guid=__files_GUID_50489A8A_457C_4B54_80E1_5572A16F7F17_htm)。

有人知道如何使用Python FBX SDK将* .obj转换为* .fbx吗?

感谢。

1 个答案:

答案 0 :(得分:4)

Python FBX SDK缺乏良好的文档。以下是您可以使用它的方法。

import fbx

# Create an SDK manager                                                                                           
manager = fbx.FbxManager.Create()

# Create a scene
scene = fbx.FbxScene.Create(manager, "")

# Create an importer object                                                                                                  
importer = fbx.FbxImporter.Create(manager, "")

# Path to the .obj file
milfalcon = "samples/millenium-falcon/millenium-falcon.obj"

# Specify the path and name of the file to be imported                                                                            
importstat = importer.Initialize(milfalcon, -1)

importstat = importer.Import(scene)

# Create an exporter object                                                                                                  
exporter = fbx.FbxExporter.Create(manager, "")

save_path = "samples/millenium-falcon/millenium-falcon.fbx"

# Specify the path and name of the file to be imported                                                                            
exportstat = exporter.Initialize(save_path, -1)

exportstat = exporter.Export(scene)

您可以选择使用例如

设置导出(和导入)选项
ios = fbx.FbxIOSettings.Create(manager, fbx.IOSROOT)
manager.SetIOSettings(ios)

manager.GetIOSettings().SetBoolProp(fbx.EXP_FBX_SHAPE, False)
manager.GetIOSettings().SetBoolProp(fbx.EXP_FBX_GOBO, False)

exportstat = exporter.Initialize(save_path, -1, manager.GetIOSettings())