Skip to main content

pyfbx

A simple-to-use wrapper for Autodesk Python FBX SDK.

Credit to @jochasinga for the original library.

FBX

FBX(Filmbox) is a proprietary file format (.fbx) developed by Kaydara and owned by Autodesk since 2006. It is used to provide interoperability between digital content creation applications.

from Wikipedia

Why another wrapper?

I have had a chance to work on a project which needed Python to generate FBX file for Maya. Autodesk did a rather poor job at its Python FBX SDK such as:

  • Lack of documentation
  • C-style APIs instead of Pythonic
  • Tedious wrapper classes i.e. FbxDouble3 to wrap around C++ array.

Why build ANOTHER wrapper?

Simple put, having to compile and build FBX was a nightmare so I thought I'd provide the appropriate platform for people to fork and add their own distributions.

This is specifically, right now, for Win 32 bit, but can easily be built for linux too (will just need to test)

How it works

Classes in pyfbx does not inherit the original classes from the SDK. Each instance of the class have a private property _me which interact with the original class's instance while pyfbx "floats" above i.e.

from pyfbx import *

manager = Manager()
scene = Scene(manager)
assert isinstance(scene, pyfbx.Scene)       # True
assert isinstance(scene._me, fbx.FbxScene)  # True

Install

git clone https://github.com/nannafudge/pyfbx
cd pyfbx && python setup.py install

Examples

from pyfbx import * 

manager = Manager()
scene = Scene(manager)
node = Node(manager)
mesh = Mesh(manager)

# Set mesh attributes 

node.add_attribute(mesh)
scene.root_node.add_child(node)

However, since Manager and Scene is a singleton in charge of all the nodes, it makes sense for them to be atomic.

manager = Manager()
manager.create_scene()    # equivalent to `Scene(manager)`
manager.create_node()     # equivalent to `Node(manager)`
scene = manager.scene
scene.create_node()       # equivalent to `Node(scene)

Node Tree

FBX depends on node hierachy, with the scene's root node acting as the descendent of all. While you can always use the underlying API to traverse through nodes in the scene, Node also keeps track of its children using simple list.

from pyfbx import *

manager = Manager()
p_node = Node(manager, "parent_node")
node.add_child(Node(manager, "child_node_1"))
node.add_child(Node(manager, "child_node_2"))

assert p_node.children[0].name == "child_node_1"

c_node_1 = node.children[0]
c_node_1.add_child(Node(manager, "grandchild_node"))

assert p_node.children[0].children[0].name == "grandchild_node"

Metadata

Release files for py-fbx 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for py-fbx 0.1.1
File Interpreter ABI Platform
py_fbx-0.1.1-py3-none-any.whl Python 3 none any Details

Release files / py_fbx-0.1.1-py3-none-any.whl

Download URL py_fbx-0.1.1-py3-none-any.whl
Size 2.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a473271d1cb69d784a29419ed79165131acdbeb79504124601970c20f1f8c0f2
BLAKE2b-256 checksum
How to use checksums
d910eb1fa9d4b03d50ba332901befb2489230d9dd7dbec4539530d55fd6b8cae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page