Skip to content

Commit 8e933cd

Browse files
Cleanup attribute enums and types (#72)
* Cleanup attribute enums and types * update CI * Fix some bugs; support new 5.2 attributes * ruff format & ty check --fix * Update test-in-blender.yml * GeometrySet support * dev dependency groups
1 parent af1e876 commit 8e933cd

18 files changed

Lines changed: 910 additions & 172 deletions

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
- name: Build Docs
2323
run: |
24-
uv sync --all-extras --dev
24+
uv sync --all-extras
2525
uv pip install -e .
2626
cd docs
2727
uv run -m quartodoc build

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v4
1616
- uses: actions/setup-python@v5
1717
with:
18-
python-version: "3.11"
18+
python-version: "3.13"
1919
- name: Install ruff
2020
run: pip install ruff
2121
- name: Check code formatting

.github/workflows/test-daily.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ jobs:
2020
version: ${{ matrix.version }}
2121
- name: Install in Blender
2222
run: |
23-
blender -b -P tests/python.py -- -m pip install ".[dev]"
23+
blender -b -P tests/python.py -- -m pip install --upgrade pip
24+
blender -b -P tests/python.py -- -m pip install . --group dev
2425
- name: Run Tests
2526
run: |
2627
blender -b -P tests/run.py -- -vv tests --cov --cov-report=xml

.github/workflows/test-in-blender.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
max-parallel: 4
1414
fail-fast: false
1515
matrix:
16-
version: ["5.1", "5.2", "daily"]
16+
version: ["5.2", "daily"]
1717
os: [macos-14, ubuntu-latest, windows-latest]
1818
steps:
1919
- uses: actions/checkout@v4
@@ -22,5 +22,6 @@ jobs:
2222
version: ${{ matrix.version }}
2323
- name: Install and Test
2424
run: |
25-
blender -b -P tests/python.py -- -m pip install -e ".[dev]"
25+
blender -b -P tests/python.py -- -m pip install --upgrade pip
26+
blender -b -P tests/python.py -- -m pip install -e . --group dev
2627
blender -b -P tests/run.py -- -vv

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
max-parallel: 4
1414
fail-fast: false
1515
matrix:
16-
version: ["5.1", "5.2"]
16+
version: ["5.2", "5.3"]
1717
os: [macos-latest, windows-latest, ubuntu-latest]
1818
steps:
1919
- uses: actions/checkout@v4
@@ -34,11 +34,11 @@ jobs:
3434
3535
- name: Upload coverage reports to Codecov
3636
uses: codecov/codecov-action@v5
37-
if: matrix.os == 'macos-latest' && matrix.version == '5.1'
37+
if: matrix.os == 'macos-latest' && matrix.version == '5.2'
3838
with:
3939
token: ${{ secrets.CODECOV_TOKEN }}
4040
name: coverage.xml
4141

4242
- name: Upload coverage reports to Codecov
43-
if: matrix.os == 'macos-latest' && matrix.version == '5.1'
43+
if: matrix.os == 'macos-latest' && matrix.version == '5.2'
4444
uses: codecov/codecov-action@v3

docs/_quarto.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ website:
1818
text: Attributes
1919
- href: api/index.qmd
2020
text: API
21+
- href: changelog.qmd
22+
text: Changelog
2123
tools:
2224
- icon: github
2325
href: https://github.com/BradyAJohnston/databpy
@@ -91,6 +93,7 @@ quartodoc:
9193
- create_pointcloud_object
9294
- create_bob
9395
- evaluate_object
96+
- GeometrySet
9497
- BlenderObject
9598
- BlenderObjectAttribute
9699
- BlenderObjectBase

docs/_variables.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version: 0.7.0
1+
version: 0.8.0

docs/changelog.qmd

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
title: Changelog
3+
toc: true
4+
---
5+
6+
## 0.8.0 (unreleased)
7+
8+
Support for the new attribute types introduced in Blender 5.2, alongside a cleanup
9+
of the attribute typing system. Requires `bpy >= 5.2`.
10+
11+
### Added
12+
13+
- Support for the new Blender 5.2 attribute types:
14+
- `FLOAT4` — 4D float vectors ([`Float4Attribute`](https://docs.blender.org/api/current/bpy.types.Float4Attribute.html))
15+
- `INT16_2D` — 2D 16-bit signed integer vectors ([`Short2Attribute`](https://docs.blender.org/api/current/bpy.types.Short2Attribute.html))
16+
- `STRING` — text strings ([`StringAttribute`](https://docs.blender.org/api/current/bpy.types.StringAttribute.html)).
17+
String support is *experimental* and raises a warning when used: string
18+
attributes are accessible through the Python API but are not yet properly
19+
supported within Geometry Nodes. Values are read and written per-element
20+
(as unicode numpy arrays) since Blender's `foreach_get`/`foreach_set` do not
21+
support string properties.
22+
23+
- `GeometrySet`, for accessing all components of an object's evaluated geometry —
24+
including multi-component Geometry Nodes outputs (mesh, point cloud, curves and
25+
instances) that a normally evaluated object doesn't expose. Provides
26+
`named_attribute()` / `list_attributes()` across components and an informative
27+
`repr()` suited to snapshot testing.
28+
- `Attribute.storage_type`, exposing Blender 5.2's new attribute storage types
29+
(`"ARRAY"` or `"SINGLE"`). `SINGLE`-storage attributes (produced by Geometry
30+
Nodes for constant values) read transparently as full arrays.
31+
- `named_attribute(evaluate=True)` and `evaluate_object()` now work for Curves and
32+
PointCloud objects, not just meshes.
33+
- `BlenderObject.store_named_attribute()` now returns the created or modified
34+
attribute (previously returned `None`).
35+
36+
### Changed
37+
38+
- Results of `AttributeArray` operations (e.g. `pos + 1`, comparisons) are now
39+
plain `numpy.ndarray`s, and copies (`pos.copy()`, boolean-mask indexing) are
40+
detached from Blender — neither syncs back on modification. True views
41+
(slices, column access) remain connected and continue to auto-sync.
42+
- Data is cast to the attribute's storage dtype before writing, letting Blender's
43+
`foreach_set` use its fast buffer path instead of per-element iteration
44+
(a significant speedup for the common case of passing float64 arrays).
45+
- **Breaking**: attribute type guessing for `(n, 4)` float arrays now maps to the
46+
generic `FLOAT4` type instead of `FLOAT_COLOR`. To store colors or quaternions,
47+
explicitly request them with e.g. `store_named_attribute(..., atype="FLOAT_COLOR")`.
48+
`(n, 4)` `uint8` arrays still map to `BYTE_COLOR`.
49+
- Attribute type guessing for `(n, 2)` `int16` / `uint16` arrays now maps to
50+
`INT16_2D` (other integer widths still map to `INT32_2D`), and string arrays
51+
map to `STRING`.
52+
- Requires `bpy >= 5.2` (previously `>= 5.1`).
53+
- Improved type hints throughout the attribute module: precise `Literal` types for
54+
attribute type and domain names, `tuple[int, ...]` shapes, and an immutable
55+
`AttributeType` dataclass.
56+
57+
### Fixed
58+
59+
- Setting an existing attribute with dictionary syntax (`bob["color"] = data`) no
60+
longer performs a second, redundant write with a re-guessed attribute type,
61+
which could raise a type mismatch error for color and quaternion attributes.
62+
- `Attribute.from_array()` now triggers the same object-data refresh workaround as
63+
`store_named_attribute()`, so writes through the low-level interface update
64+
reliably in the viewport.
65+
- `repr()` of an `AttributeArray` that has lost its attribute reference no longer
66+
raises an error.
67+
68+
### Removed
69+
70+
- **Breaking**: removed the unused legacy `AttributeTypeInfo` and `AttributeDomain`
71+
classes from the public API. Use the `AttributeTypes` and `AttributeDomains`
72+
enums instead.
73+
74+
## 0.7.0 (2026-03-05)
75+
76+
- Updated dependencies for Blender 5.1 ([#69](https://github.com/BradyAJohnston/databpy/pull/69)).
77+
78+
## 0.6.2 (2026-03-05)
79+
80+
- Improved typing for the attribute module ([#67](https://github.com/BradyAJohnston/databpy/pull/67)).
81+
- Added `move_to_collection()` for moving objects from one collection into another
82+
([#62](https://github.com/BradyAJohnston/databpy/pull/62), thanks [\@kolibril13](https://github.com/kolibril13)).
83+
84+
## 0.6.0 (2025-11-25)
85+
86+
- Refactored object classes around a more minimal `BlenderObjectBase`
87+
([#61](https://github.com/BradyAJohnston/databpy/pull/61),
88+
[#63](https://github.com/BradyAJohnston/databpy/pull/63)).
89+
90+
## 0.5.1 (2025-11-06)
91+
92+
- General cleanup ([#58](https://github.com/BradyAJohnston/databpy/pull/58)).
93+
- Improved deduplication method ([#60](https://github.com/BradyAJohnston/databpy/pull/60)).
94+
95+
## 0.5.0 (2025-10-25)
96+
97+
- Better point cloud and curves support ([#57](https://github.com/BradyAJohnston/databpy/pull/57)).
98+
- Requires Blender >= 4.5 for compatibility with point cloud support.
99+
100+
## 0.4.2 (2025-10-24)
101+
102+
- Internal improvements and cleanup ([#56](https://github.com/BradyAJohnston/databpy/pull/56)).
103+
- Deprecated `Attribute.n_values` in favor of `Attribute.size`.
104+
105+
## 0.4.1 (2025-10-21)
106+
107+
- Fixed `AttributeArray.__str__` ([#55](https://github.com/BradyAJohnston/databpy/pull/55)).
108+
109+
## 0.4.0 (2025-10-21)
110+
111+
- Fixed integer attribute returns to be `int32` ([#54](https://github.com/BradyAJohnston/databpy/pull/54)).
112+
113+
---
114+
115+
For older releases, see the [GitHub releases page](https://github.com/BradyAJohnston/databpy/releases).

pyproject.toml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "databpy"
3-
version = "0.7.0"
3+
version = "0.8.0"
44
description = "A data-oriented wrapper library for the Blender Python API"
55
readme = "README.md"
66
dependencies = [
@@ -23,7 +23,14 @@ build-backend = "uv_build"
2323

2424

2525
[project.optional-dependencies]
26-
bpy = ["bpy>=5.1"]
26+
bpy = ["bpy>=5.2"]
27+
28+
[tool.uv.workspace]
29+
members = [
30+
".",
31+
]
32+
33+
[dependency-groups]
2734
dev = [
2835
"fake-bpy-module",
2936
"polars",
@@ -32,10 +39,6 @@ dev = [
3239
"jupyter",
3340
"polars",
3441
"pytest",
35-
"pytest-cov"
36-
]
37-
38-
[tool.uv.workspace]
39-
members = [
40-
".",
42+
"pytest-cov",
43+
"nodebpy>=520.8.0",
4144
]

src/databpy/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from .utils import centre, lerp
2020
from .collection import create_collection, move_to_collection
2121
from .array import AttributeArray
22+
from .geometry import GeometrySet
2223
from .attribute import (
2324
named_attribute,
2425
store_named_attribute,
@@ -27,10 +28,8 @@
2728
evaluate_object,
2829
Attribute,
2930
AttributeType,
30-
AttributeTypeInfo,
3131
AttributeTypes,
3232
AttributeDomains,
33-
AttributeDomain,
3433
NamedAttributeError,
3534
AttributeMismatchError,
3635
)
@@ -58,17 +57,16 @@
5857
"create_collection",
5958
"move_to_collection",
6059
"AttributeArray",
60+
"GeometrySet",
6161
"named_attribute",
6262
"store_named_attribute",
6363
"remove_named_attribute",
6464
"list_attributes",
6565
"evaluate_object",
6666
"Attribute",
6767
"AttributeType",
68-
"AttributeTypeInfo",
6968
"AttributeTypes",
7069
"AttributeDomains",
71-
"AttributeDomain",
7270
"NamedAttributeError",
7371
"AttributeMismatchError",
7472
]

0 commit comments

Comments
 (0)