From e8ab30ab3ed5e7776dd5ac7b21fec475261ef65c Mon Sep 17 00:00:00 2001 From: Ryan Schultz Date: Fri, 27 Mar 2026 11:56:20 -0500 Subject: [PATCH] Fix for #7861 and #7801: Fix error in assign_container for unloaded elements Decomposed elements collected via get_decomposition may not have a corresponding Blender object if they are not loaded into the scene. Guard against None before calling collector.assign. Regression introduced in ff35666ad. Generated with the assistance of an AI coding tool. --- src/bonsai/bonsai/core/spatial.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bonsai/bonsai/core/spatial.py b/src/bonsai/bonsai/core/spatial.py index 5ce6d7c253..3af14821a2 100644 --- a/src/bonsai/bonsai/core/spatial.py +++ b/src/bonsai/bonsai/core/spatial.py @@ -67,7 +67,8 @@ def assign_container( if products := [e for e in root_elements if spatial.can_contain(container, root_element)]: ifc.run("spatial.assign_container", products=products, relating_structure=container) for element in all_elements: - collector.assign(ifc.get_object(element)) + if obj := ifc.get_object(element): + collector.assign(obj) def enable_editing_container(spatial: type[tool.Spatial], obj: bpy.types.Object) -> None: