简体   繁体   English

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

[英]Convert *.obj to *.fbx with Python FBX SDK

I try to find some documentation for Autodesk Python FBX SDK, but it seems that it is available only for C++ ( http://help.autodesk.com/view/FBX/2015/ENU/?guid=__files_GUID_50489A8A_457C_4B54_80E1_5572A16F7F17_htm ). 我尝试找到一些有关Autodesk Python FBX SDK的文档,但似乎仅适用于C ++( http://help.autodesk.com/view/FBX/2015/ENU/?guid=__files_GUID_50489A8A_457C_4B54_80E1_5572A16F7F17_htm )。

Does somebody know how convert *.obj to *.fbx with using Python FBX SDK? 有人知道如何使用Python FBX SDK将* .obj转换为* .fbx吗?

Thanks. 谢谢。

Python FBX SDK lacks good documentation. Python FBX SDK缺少好的文档。 Here is how you might get it to work. 这是您可能使其工作的方式。

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)

Optionally, you can set export (and import) options with ie 您也可以选择使用以下方式设置导出(和导入)选项:

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())

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM