databpy reads and writes the attributes of mesh, curves and point cloud objects in Blender as NumPy arrays, and creates those objects from arrays. It supports Blender 5.1 and later.
import numpy as np
import databpy as db
# create a mesh object from an (n, 3) array of vertex positions
bob = db.create_bob(np.random.rand(100, 3), name="Points")
# store and read attributes as NumPy arrays; the type is inferred from the dtype
bob.store_named_attribute(np.arange(100), "id")
ids = bob.named_attribute("id")
# attributes as arrays that write changes back to Blender
bob.position[:, 2] += 1.0
bob["id"][:10] = -1store_named_attribute() and named_attribute() are named after the Store Named Attribute and Named Attribute nodes in Geometry Nodes.
databpy builds meshes by writing arrays straight to their attributes, rather than through Mesh.from_pydata(), and an attribute array writes back only the values that change:
| Operation | bpy |
databpy | Speedup |
|---|---|---|---|
| Mesh from 100,000 vertices | 37 ms | 0.14 ms | ~260x |
| Mesh from 100,000 vertices and 99,999 edges | 62 ms | 0.24 ms | ~260x |
| Mesh from 90,000 vertices and 89,401 quads | 101 ms | 5.0 ms | ~20x |
| Write 10 values of a 1,000,000 point attribute | 0.28 ms | 0.006 ms | ~45x |
The bpy column uses Mesh.from_pydata() for meshes, and for the attribute write a foreach_get and foreach_set round trip of the whole attribute. Times are medians of the workloads in benchmarks/test_benchmarks.py, measured with bpy 5.2.1 and Python 3.13 on an AMD Ryzen 9 9950X (Linux), and vary by machine. CodSpeed tracks the benchmarks on every pull request.
pip install databpybpy (Blender as a Python module) is an optional dependency, so installing databpy inside Blender doesn't install a second copy of bpy. To use databpy outside Blender, install bpy with it:
pip install "databpy[bpy]"| Blender | Tests |
|---|---|
| 5.1 | |
| 5.2 | |
| 5.3 (beta) | |
| 5.4 (alpha) |
databpy requires Python 3.13, the version Blender 5.1 and 5.2 use.
- Getting started: storing and reading attributes,
BlenderObject, and importing a table with Polars - Attributes guide: attribute types and domains, syncing, performance and errors
- API reference
- Changelog
databpy started inside Molecular Nodes and was split into a separate package for use in other projects, similarly to nodebpy.
