Fast, Pythonic bindings for the ufbx FBX file loader
Project description
pufbx
Fast, Pythonic bindings for the ufbx FBX file loader by Samuli Raivio (@bqqbarbhg).
pufbx wraps the battle-tested C library ufbx via Cython, giving you high-performance access to FBX scene data — nodes, meshes, bones, animations, materials, and more — without writing a single line of C.
Project status: alpha. Planned scope is everything ufbx defines for reading FBX (its public types, fields, lists, and loader-facing API). Rough completion: ~35% toward that bar (informal): many wrappers exist, but exhaustive parity and polish across the full ufbx surface are still in progress. Version 0.1.0 focused on animation — scene load, bake, dense numpy export (anim_to_array), and raw curves.
Features
- Fast — thin Cython layer over native C; loads large FBX files in milliseconds
- Pythonic API — scene-graph traversal, properties, iteration,
len(), and numpy arrays - Animation baking —
bake_anim()composites full transform chains into quaternion keyframes - Dense export —
anim_to_array()returns(nodes × frames × 10)numpy arrays ready for ML pipelines - Raw curves — access original Euler-angle keyframes with Bezier tangent handles
- Cross-platform — Linux, macOS, and Windows wheels for Python 3.9–3.13
Installation
From PyPI
pip install pufbx
From source
git clone https://github.com/Owca-Xsido/pufbx.git
cd pufbx
uv sync --extra dev
Note: Building from source requires a C compiler and Python development headers (
python3-dev/python3.x-devon Debian/Ubuntu).
Quick start
Load a scene and traverse nodes
import pufbx
scene = pufbx.load_fbx("character.fbx")
print(f"Nodes: {len(scene.nodes)}")
for node in scene.nodes:
indent = " " * node.node_depth
print(f"{indent}{node.name} type={node.attrib_type}")
Bake animation to quaternion keyframes
import pufbx
scene = pufbx.load_fbx("character.fbx")
baked = pufbx.bake_anim(scene)
for node in baked.modified_nodes:
r = node.rotation_keys
print(f"Node {node.typed_id}: {len(r)} rotation keyframes")
Export dense numpy array (ML-ready)
import pufbx
data, times, names = pufbx.anim_to_array("character.fbx")
# data.shape → (num_nodes, num_frames, 10)
# channels: [tx, ty, tz, rx, ry, rz, rw, sx, sy, sz]
Examples
See the examples/ directory for complete, runnable scripts:
| Script | Description |
|---|---|
01_load_scene.py |
Load a scene and print the node hierarchy |
02_bake_rotation.py |
Bake animation and read rotation quaternions |
03_anim_to_array.py |
Export animation to a dense numpy array |
04_raw_curves.py |
Access raw Euler-angle curves with Bezier tangents |
Development
Install uv, then:
git clone https://github.com/Owca-Xsido/pufbx.git
cd pufbx
uv sync --extra dev
uv run python -m pytest tests/
Formatting & linting
uv run black pufbx/ tests/
uv run isort pufbx/ tests/
How it works
pufbx vendors the ufbx C source (by
Samuli Raivio) and compiles it into a shared
Cython extension. On Linux/macOS, ufbx_wrapper is loaded with RTLD_GLOBAL
so all extension modules share a single copy of the ufbx C symbols (required
for ufbx string interning via pointer identity).
License
MIT — see the license file for details.
The vendored ufbx library is Copyright (c) 2020 Samuli Raivio (@bqqbarbhg), available under the MIT License or the Unlicense (public domain) at your option.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pufbx-0.1.0.tar.gz.
File metadata
- Download URL: pufbx-0.1.0.tar.gz
- Upload date:
- Size: 4.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81e532d22ed652d1c8955d34321d4ac33b9f7a9e9632b94da96e221f13ce66ed
|
|
| MD5 |
0dae1320eeebe395fbc09ef792b21c4f
|
|
| BLAKE2b-256 |
a8d82ffb268bbbf34db723a7360e1cf73b894232de2d08f6031b02c7ca9288ac
|
File details
Details for the file pufbx-0.1.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: pufbx-0.1.0-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 6.2 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
034ca2c9b638a33781890b19c1d4e35645786f5c4d2213b0202d4801f10a2498
|
|
| MD5 |
a8207929410cef576a3afdf44a3dae2b
|
|
| BLAKE2b-256 |
ba59eac089af1e907392a0f9c9ed861c619cb5ac5684a16ef7494f6210861866
|