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:
committed by
Sybren A. Stüvel
parent
b1c4f5e116
commit
c69612b264
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user