Skip to main content

databpy

codecov pypi tests deployment

A set of data-oriented wrappers around the python API of Blender.

This was originally used internally inside of Molecular Nodes but was broken out into a separate python module for re-use in other projects.

Installation

Available on PyPI, install with pip:

pip install databpy

[!CAUTION]

bpy (Blender as a python module) is listed as an optional dependency, so that if you install databpy inside of Blender you won’t install a redundant version of bpy. If you are using this outside of Blender, you will need to specifically request bpy with either of these methods:

# install wtih bpy dependency
pip install "databpy[bpy]"

# install both packages
pip install databpy bpy

# install with all optional dependencies
pip install "databpy[all]"

Usage

The main use cases are to create objects, store and retrieve attributes from them. The functions are named around nodes in Geometry Nodes Store Named Attribute and Named Attribute

import databpy as db

# store and retrieve attributes from a mesh, point cloud, or curves object
db.store_named_attribute()
db.named_attribute()

Here’s an example on how to store an attribute:

import numpy as np
import databpy as db

coords = np.array([[0, 0, 0], [0, 5, 0], [5, 0, 0], [5, 5, 0]]))

obj = db.create_object(coords, name="Box")
db.store_named_attribute(obj, np.array([10, 20, 31, 42]), "vals")

image

This module is mainly used to create mesh objects and work with their attributes. It is built to store and retrieve data using NumPy arrays:

import numpy as np
import databpy as db

np.random.seed(6)

# Create a mesh object
random_verts = np.random.rand(10, 3)

obj = db.create_object(random_verts, name="RandomMesh")

obj.name
'RandomMesh'

Access attributes from the object’s mesh.

db.named_attribute(obj, "position")
array([[0.8928602 , 0.3319798 , 0.8212291 ],
       [0.04169663, 0.10765668, 0.59505206],
       [0.52981734, 0.41880742, 0.33540785],
       [0.62251943, 0.43814144, 0.7358821 ],
       [0.5180364 , 0.5788586 , 0.6453551 ],
       [0.99022424, 0.8198582 , 0.41320094],
       [0.8762677 , 0.82375944, 0.05447451],
       [0.7186372 , 0.8021706 , 0.7364066 ],
       [0.7091318 , 0.5409368 , 0.12482417],
       [0.9576473 , 0.4032563 , 0.21695116]], dtype=float32)

BlenderObject class (bob)

This is a convenience class that wraps around the bpy.types.Object, and provides access to all of the useful functions. We can wrap an existing Object or return one when creating a new object.

This just gives us access to the named_attribute() and store_named_attribute() functions on the object class, but also provides a more intuitive way to access the object’s attributes.

# wrap an existing object or create a new one
bob = db.BlenderObject(obj)
bob = db.create_bob(random_verts)

# these two are identical
bob.named_attribute("position")
bob.position
AttributeArray(name='position', object='NewObject', mesh='NewObject', domain=POINT, type=FLOAT_VECTOR, shape=(10, 3), dtype=float32)
array([[0.8928602 , 0.3319798 , 0.8212291 ],
       [0.04169663, 0.10765668, 0.59505206],
       [0.52981734, 0.41880742, 0.33540785],
       [0.62251943, 0.43814144, 0.7358821 ],
       [0.5180364 , 0.5788586 , 0.6453551 ],
       [0.99022424, 0.8198582 , 0.41320094],
       [0.8762677 , 0.82375944, 0.05447451],
       [0.7186372 , 0.8021706 , 0.7364066 ],
       [0.7091318 , 0.5409368 , 0.12482417],
       [0.9576473 , 0.4032563 , 0.21695116]], dtype=float32)

We can clear all of the data from the object and initialise a new mesh underneath:

bob.new_from_pydata(np.random.randn(5, 3))
bob.position
AttributeArray(name='position', object='NewObject', mesh='NewObject', domain=POINT, type=FLOAT_VECTOR, shape=(5, 3), dtype=float32)
array([[ 0.82465386, -1.1764315 ,  1.5644896 ],
       [ 0.7127051 , -0.1810066 ,  0.53419954],
       [-0.58661294, -1.4818532 ,  0.8572476 ],
       [ 0.94309896,  0.11444143, -0.02195668],
       [-2.1271446 , -0.83440745, -0.4655083 ]], dtype=float32)

Example with Polars data

import polars as pl
import databpy as db
from io import StringIO

json_file = StringIO("""
{
  "Dino": [
    [55.3846, 97.1795, 0.0],
    [51.5385, 96.0256, 0.0]
  ],
  "Star": [
    [58.2136, 91.8819, 0.0],
    [58.1961, 92.215, 0.0]
  ]
}
""")

df = pl.read_json(json_file)
columns_to_explode = [col for col in df.columns if df[col].dtype == pl.List(pl.List)]
df = df.explode(columns_to_explode)

vertices = np.zeros((len(df), 3), dtype=np.float32)
bob = db.create_bob(vertices, name="DinoStar")

for col in df.columns:
    data = np.vstack(df.get_column(col).to_numpy())
    bob.store_named_attribute(data, col)

bob.named_attribute("Dino")
array([[55.3846, 97.1795,  0.    ],
       [51.5385, 96.0256,  0.    ]], dtype=float32)
bob.named_attribute("Star")
array([[58.2136, 91.8819,  0.    ],
       [58.1961, 92.215 ,  0.    ]], dtype=float32)

Metadata

Release files for databpy 0.9.0

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

Source distribution (sdist)

Source distribution for databpy 0.9.0
File Size Uploaded
databpy-0.9.0.tar.gz 31.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for databpy 0.9.0
File Interpreter ABI Platform
databpy-0.9.0-py3-none-any.whl Python 3 none any Details

Total release size: 69.2 kB

Release files / databpy-0.9.0.tar.gz

Download URL databpy-0.9.0.tar.gz
Size 31.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9392041193b77d46c6900c73cb562669f2c57c27bd9a83db24f13d624105e74b
BLAKE2b-256 checksum
How to use checksums
189731a05c04839706ffad287db4d190d9dbb245c66d794a4c7f66c37a60602a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release files / databpy-0.9.0-py3-none-any.whl

Download URL databpy-0.9.0-py3-none-any.whl
Size 37.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e0ea93c803b8fca7eac6d617d4951e435364de4e811548eef596526990acdb2
BLAKE2b-256 checksum
How to use checksums
3e2ee70885a4b2c29c217373163ecd48d75a28b4b34d94819f3c45ac0e62d003
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release history Release notifications | RSS feed

0.10.0

2 release files

This release

0.9.0 This release

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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