From 2d0aaedb7fdabb38761f54ed04cce12a8cf7b3b9 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Wed, 11 Dec 2024 10:45:41 +0100 Subject: [PATCH] BIM: Fixes appearance defects coming from recent transparency and #18298 --- src/Mod/BIM/nativeifc/ifc_generator.py | 14 ++++++++++++-- src/Mod/BIM/nativeifc/ifc_tools.py | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Mod/BIM/nativeifc/ifc_generator.py b/src/Mod/BIM/nativeifc/ifc_generator.py index 578fe3c368..583dac7a24 100644 --- a/src/Mod/BIM/nativeifc/ifc_generator.py +++ b/src/Mod/BIM/nativeifc/ifc_generator.py @@ -464,13 +464,23 @@ def set_cache(ifcfile, cache): def set_representation(vobj, node): """Sets the correct coin nodes for the given Part object""" + def find_node(parent, nodetype): + for i in range(parent.getNumChildren()): + if isinstance(parent.getChild(i), nodetype): + return parent.getChild(i) + return None + # node = [colors, verts, faces, edges, parts] if not vobj.RootNode: return if vobj.RootNode.getNumChildren() < 3: return - coords = vobj.RootNode.getChild(1) # SoCoordinate3 - switch = vobj.RootNode.getChild(2) + coords = find_node(vobj.RootNode, coin.SoCoordinate3) + if not coords: + return + switch = find_node(vobj.RootNode, coin.SoSwitch) + if not switch: + return num_modes = switch.getNumChildren() if num_modes < 3: return diff --git a/src/Mod/BIM/nativeifc/ifc_tools.py b/src/Mod/BIM/nativeifc/ifc_tools.py index 2b98c240a1..1c3dd9aa39 100644 --- a/src/Mod/BIM/nativeifc/ifc_tools.py +++ b/src/Mod/BIM/nativeifc/ifc_tools.py @@ -942,7 +942,7 @@ def set_colors(obj, colors): if len(colors) > 1: #colors[0] = colors[0][:3] + (0.0,) # TEMP HACK: if multiple colors, set everything to opaque because it looks wrong - colors = [color[:3] + (0.0,) for color in colors] + colors = [color[:3] + (1.0,) for color in colors] sapp = [] for color in colors: sapp_mat = FreeCAD.Material()