From 2c16839de7005ec15c94320a717752a17be1481d Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 5 Mar 2025 17:28:55 +0500 Subject: [PATCH] Fix parametric stairs/railings/roofs not updating ifc link after representation update #6264 Related to 3107fd9 --- src/bonsai/bonsai/tool/model.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/bonsai/bonsai/tool/model.py b/src/bonsai/bonsai/tool/model.py index 31069b1d19..62cabec1b5 100644 --- a/src/bonsai/bonsai/tool/model.py +++ b/src/bonsai/bonsai/tool/model.py @@ -1002,8 +1002,11 @@ class Model(bonsai.core.tool.Model): obj: bpy.types.Object, new_representation: ifcopenshell.entity_instance, ) -> None: + mesh = obj.data + assert isinstance(mesh, bpy.types.Mesh) ifc_file = tool.Ifc.get() ifc_element = tool.Ifc.get_entity(obj) + assert ifc_element old_representation = ifcopenshell.util.representation.get_representation( ifc_element, ifc_context.ContextType, ifc_context.ContextIdentifier, ifc_context.TargetView ) @@ -1017,6 +1020,15 @@ class Model(bonsai.core.tool.Model): ifcopenshell.api.run( "geometry.assign_representation", ifc_file, product=ifc_element, representation=new_representation ) + bonsai.core.geometry.switch_representation( + tool.Ifc, + tool.Geometry, + obj=obj, + representation=new_representation, + should_reload=True, + is_global=True, + should_sync_changes_first=False, + ) @classmethod def update_thumbnail_for_element(cls, element: ifcopenshell.entity_instance, refresh: bool = False) -> None: