From 72aaf182ea3c2eda94f33cd720d44dd1a09cfae4 Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Mon, 1 Jan 2024 15:38:29 +0100 Subject: [PATCH] Arch: Arch_Project avoid ghosts of objects in Group --- src/Mod/Arch/ArchProject.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Mod/Arch/ArchProject.py b/src/Mod/Arch/ArchProject.py index 4a685ddd9c..b364ed0ac2 100644 --- a/src/Mod/Arch/ArchProject.py +++ b/src/Mod/Arch/ArchProject.py @@ -200,5 +200,24 @@ class _ViewProviderProject(ArchIFCView.IfcContextView): import Arch_rc return ":/icons/Arch_Project_Tree.svg" + def removeDisplaymodeChildNodes(self,vobj): + """Remove all child nodes from the 4 default display modes. + + This avoids 'ghosts' of the objects in the Group property. + See: + ArchSite.py + https://forum.freecad.org/viewtopic.php?f=10&t=74731 + """ + + if not hasattr(self, "displaymodes_cleaned"): + main_switch = vobj.RootNode.getChild(2) # The display mode switch. + if main_switch is not None and main_switch.getNumChildren() == 4: # Check if all display modes are available. + for node in tuple(main_switch.getChildren()): + node.removeAllChildren() + self.displaymodes_cleaned = True + + def onChanged(self,vobj,prop): + self.removeDisplaymodeChildNodes(vobj) + if FreeCAD.GuiUp: FreeCADGui.addCommand('Arch_Project', _CommandProject())