From 3e9089bd47cb027c614b5968eb1c3745ddc7268d Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Mon, 7 Jul 2025 14:45:07 +0200 Subject: [PATCH] BIM: fix handling of Project coin nodes (#22244) * Update ArchProject.py * Update ArchSite.py --- src/Mod/BIM/ArchProject.py | 7 +++++-- src/Mod/BIM/ArchSite.py | 15 ++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/Mod/BIM/ArchProject.py b/src/Mod/BIM/ArchProject.py index 7374824f0f..6d16ad1c00 100644 --- a/src/Mod/BIM/ArchProject.py +++ b/src/Mod/BIM/ArchProject.py @@ -137,9 +137,12 @@ class _ViewProviderProject(ArchIFCView.IfcContextView): https://forum.freecad.org/viewtopic.php?f=10&t=74731 """ + from pivy import coin + from draftutils import gui_utils + if not hasattr(self, "displaymodes_cleaned"): - if vobj.RootNode.getNumChildren() > 2: - main_switch = vobj.RootNode.getChild(2) # The display mode switch. + if vobj.RootNode.getNumChildren(): + main_switch = gui_utils.find_coin_node(vobj.RootNode, coin.SoSwitch) # 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() diff --git a/src/Mod/BIM/ArchSite.py b/src/Mod/BIM/ArchSite.py index 2d80e8f825..13693bb6ee 100644 --- a/src/Mod/BIM/ArchSite.py +++ b/src/Mod/BIM/ArchSite.py @@ -978,19 +978,12 @@ class _ViewProviderSite: """ from pivy import coin - - def find_node(parent, nodetype): - for i in range(parent.getNumChildren()): - if isinstance(parent.getChild(i), nodetype): - return parent.getChild(i) - return None + from draftutils import gui_utils if not hasattr(self, "terrain_switches"): - if vobj.RootNode.getNumChildren() > 2: - main_switch = find_node(vobj.RootNode, coin.SoSwitch) - if not main_switch: - return - if main_switch.getNumChildren() == 4: # Check if all display modes are available. + if vobj.RootNode.getNumChildren(): + main_switch = gui_utils.find_coin_node(vobj.RootNode, coin.SoSwitch) # The display mode switch. + if main_switch is not None and main_switch.getNumChildren() == 4: # Check if all display modes are available. self.terrain_switches = [] for node in tuple(main_switch.getChildren()): new_switch = coin.SoSwitch()