From 584614bb010b631a37dd85f91e4118cdf0656cef Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Mon, 22 Dec 2025 03:16:17 +0100 Subject: [PATCH] BIM: fix deletion of BuildingPart in strict IFC mode (#26219) * BIM: fix deletion of BuildingPart in strict IFC mode Add `sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph()` to `onDelete`. * BIM: fix deletion of BuildingPart in strict IFC mode Explicitly call `obj.ViewObject.Proxy.attach(obj.ViewObject)`. * BIM: fix deletion of BuildingPart in strict IFC mode In `ifc_vp_buildingpart` call `attach` from `ArchBuildingPart.ViewProviderBuildingPart`. --- src/Mod/BIM/ArchBuildingPart.py | 1 + src/Mod/BIM/nativeifc/ifc_tools.py | 1 + src/Mod/BIM/nativeifc/ifc_viewproviders.py | 3 +++ 3 files changed, 5 insertions(+) diff --git a/src/Mod/BIM/ArchBuildingPart.py b/src/Mod/BIM/ArchBuildingPart.py index ef4b67bf9f..8f026cd51b 100644 --- a/src/Mod/BIM/ArchBuildingPart.py +++ b/src/Mod/BIM/ArchBuildingPart.py @@ -1112,6 +1112,7 @@ class ViewProviderBuildingPart: def onDelete(self, vobj, subelements): if self.clip: + sg = FreeCADGui.ActiveDocument.ActiveView.getSceneGraph() sg.removeChild(self.clip) self.clip = None for o in Draft.get_group_contents(vobj.Object.Group, walls=True): diff --git a/src/Mod/BIM/nativeifc/ifc_tools.py b/src/Mod/BIM/nativeifc/ifc_tools.py index 2f55339a91..383df7e514 100644 --- a/src/Mod/BIM/nativeifc/ifc_tools.py +++ b/src/Mod/BIM/nativeifc/ifc_tools.py @@ -575,6 +575,7 @@ def add_object(document, otype=None, oname="IfcObject"): obj.ViewObject.ShowLevel = False obj.ViewObject.ShowLabel = False obj.ViewObject.Proxy = ifc_viewproviders.ifc_vp_buildingpart(obj.ViewObject) + obj.ViewObject.Proxy.attach(obj.ViewObject) for p in obj.PropertiesList: if obj.getGroupOfProperty(p) in ["BuildingPart", "IFC Attributes", "Children"]: obj.removeProperty(p) diff --git a/src/Mod/BIM/nativeifc/ifc_viewproviders.py b/src/Mod/BIM/nativeifc/ifc_viewproviders.py index 205e99bed5..ccb76e3ba1 100644 --- a/src/Mod/BIM/nativeifc/ifc_viewproviders.py +++ b/src/Mod/BIM/nativeifc/ifc_viewproviders.py @@ -620,6 +620,9 @@ class ifc_vp_buildingpart(ifc_vp_object, ArchBuildingPart.ViewProviderBuildingPa def __init__(self, vobj): ArchBuildingPart.ViewProviderBuildingPart.__init__(self, vobj) + def attach(self, vobj): + ArchBuildingPart.ViewProviderBuildingPart.attach(self, vobj) + def overlay(icon1, icon2): """Overlays icon2 onto icon1"""