From 99fa77edee34307006cca9a4c64d4a0479771ad3 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 6 Oct 2025 17:23:23 +1100 Subject: [PATCH] Fix #6873. Bug where geometry created through sync_references didn't have item editing metadata. --- src/bonsai/bonsai/core/root.py | 4 ++++ src/bonsai/bonsai/tool/drawing.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bonsai/bonsai/core/root.py b/src/bonsai/bonsai/core/root.py index d1b88307d2..baf13695f1 100644 --- a/src/bonsai/bonsai/core/root.py +++ b/src/bonsai/bonsai/core/root.py @@ -72,6 +72,10 @@ def assign_class( """ Args: context: is not optional if `should_add_representation` is True + + TODO: Do NOT use should_add_representation. Because it internally calls + geometry.add_representation which is 1,000 lines of Blender -> IFC magic. + Instead, explicitly create a representation using tool.Geometry. """ if ifc.get_entity(obj): return diff --git a/src/bonsai/bonsai/tool/drawing.py b/src/bonsai/bonsai/tool/drawing.py index 40c29ab5d3..336b3fd0dd 100644 --- a/src/bonsai/bonsai/tool/drawing.py +++ b/src/bonsai/bonsai/tool/drawing.py @@ -1552,12 +1552,10 @@ class Drawing(bonsai.core.tool.Drawing): context=context, ifc_representation_class=None, ) + if representation := ifcopenshell.util.representation.get_representation(element, context): + cls.reload_representation(obj=obj, representation=representation) bpy.data.curves.remove(data) - assert element - representation = ifcopenshell.util.representation.get_representation(element, context) - assert representation - obj.data["ios_edges_item_ids"] = (representation.Items[0].id(),) return element @classmethod @@ -1645,6 +1643,8 @@ class Drawing(bonsai.core.tool.Drawing): context=context, ifc_representation_class=None, ) + if representation := ifcopenshell.util.representation.get_representation(element, context): + cls.reload_representation(obj=obj, representation=representation) return element @classmethod @@ -1682,6 +1682,8 @@ class Drawing(bonsai.core.tool.Drawing): context=context, ifc_representation_class=None, ) + if representation := ifcopenshell.util.representation.get_representation(element, context): + cls.reload_representation(obj=obj, representation=representation) return element @classmethod @@ -1782,6 +1784,8 @@ class Drawing(bonsai.core.tool.Drawing): context=context, ifc_representation_class=None, ) + if representation := ifcopenshell.util.representation.get_representation(element, context): + cls.reload_representation(obj=obj, representation=representation) return element @classmethod