BlendFileBlock.get to support accessing different items in the file-block (#92898)

Add an `array_index` parameter to `block.get(property_name)` to get a
specific item from an array.

Example:
```python
verts = self.bf.block_from_addr[verts_ptr]
assert verts.get(b"co") == [-1.0, -1.0, -1.0]  # index 0
assert verts.get(b"co", array_index=1) == [-1.0, -1.0, 1.0]
```

Reviewed-on: https://projects.blender.org/blender/blender-asset-tracer/pulls/92898
This commit is contained in:
Andrej730
2025-11-24 14:53:15 +01:00
committed by Sybren A. Stüvel
parent b1c4f5e116
commit c69612b264
3 changed files with 23 additions and 1 deletions
+6
View File
@@ -46,6 +46,12 @@ class BlendFileBlockTest(AbstractBlendFileTest):
mname = mesh.get((b"id", b"name"), as_str=True)
self.assertEqual("MECube³", mname)
# Try to access different file-block items.
verts_ptr = mesh.get(b"mvert")
verts = self.bf.block_from_addr[verts_ptr]
assert verts.get(b"co") == [-1.0, -1.0, -1.0]
assert verts.get(b"co", array_index=1) == [-1.0, -1.0, 1.0]
def test_get_recursive_iter(self):
ob = self.bf.code_index[b"OB"][0]
assert isinstance(ob, blendfile.BlendFileBlock)