Fix issue packing lamps with non-IES 'storage'

Lamp/light nodes might have a `storage` property that might point to an
IES texture node (which has the expected `filepath`), but not always.
The latter now no longer crashes BAT.

This fixes https://projects.blender.org/blender/blender-asset-tracer/pulls/92883
This commit is contained in:
Sybren A. Stüvel
2023-12-14 11:36:55 +01:00
parent 81ea8296da
commit 61dc5b8a23
2 changed files with 9 additions and 1 deletions
+7 -1
View File
@@ -226,5 +226,11 @@ def lamp(block: blendfile.BlendFileBlock) -> typing.Iterator[result.BlockUsage]:
storage = node.get_pointer(b"storage")
if not storage:
continue
path, field = storage.get(b"filepath", return_field=True)
# A storage block of `NodeShaderTexIES` type has a `filepath`, but not
# all types that can be pointed to by the `storage` pointer do.
path, field = storage.get(b"filepath", return_field=True, default=None)
if path is None:
continue
yield result.BlockUsage(block, path, path_full_field=field)