From 0e55ce8d9fc234b20bbc67f4be23805a28d83ba5 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Sat, 21 Jun 2025 16:10:14 +0200 Subject: [PATCH] Update ArchComponent.py --- src/Mod/BIM/ArchComponent.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/Mod/BIM/ArchComponent.py b/src/Mod/BIM/ArchComponent.py index 62f0ec7355..9c403a3606 100644 --- a/src/Mod/BIM/ArchComponent.py +++ b/src/Mod/BIM/ArchComponent.py @@ -1353,19 +1353,16 @@ class ViewProviderComponent: #print(obj.Name," : updating ",prop) if prop == "Material": - if obj.Material and ( (not hasattr(obj.ViewObject,"UseMaterialColor")) or obj.ViewObject.UseMaterialColor): + if obj.Material and getattr(obj.ViewObject,"UseMaterialColor",True): if hasattr(obj.Material,"Material"): - if 'DiffuseColor' in obj.Material.Material: - if "(" in obj.Material.Material['DiffuseColor']: - c = tuple([float(f) for f in obj.Material.Material['DiffuseColor'].strip("()").split(",")]) - if obj.ViewObject: - if obj.ViewObject.ShapeColor != c: - obj.ViewObject.ShapeColor = c - if 'Transparency' in obj.Material.Material: - t = int(obj.Material.Material['Transparency']) - if obj.ViewObject: - if obj.ViewObject.Transparency != t: - obj.ViewObject.Transparency = t + if "DiffuseColor" in obj.Material.Material: + c = tuple([float(f) for f in obj.Material.Material["DiffuseColor"].strip("()").strip("[]").split(",")]) + if obj.ViewObject.ShapeColor != c: + obj.ViewObject.ShapeColor = c + if "Transparency" in obj.Material.Material: + t = int(obj.Material.Material["Transparency"]) + if obj.ViewObject.Transparency != t: + obj.ViewObject.Transparency = t elif prop == "Shape": if obj.Base: if obj.Base.isDerivedFrom("Part::Compound"): @@ -1375,11 +1372,7 @@ class ViewProviderComponent: obj.ViewObject.update() elif prop == "CloneOf": if obj.CloneOf: - mat = None - if hasattr(obj,"Material"): - if obj.Material: - mat = obj.Material - if (not mat) and hasattr(obj.CloneOf.ViewObject,"DiffuseColor"): + if (not getattr(obj,"Material",None)) and hasattr(obj.CloneOf.ViewObject,"DiffuseColor"): if obj.ViewObject.DiffuseColor != obj.CloneOf.ViewObject.DiffuseColor: if len(obj.CloneOf.ViewObject.DiffuseColor) > 1: obj.ViewObject.DiffuseColor = obj.CloneOf.ViewObject.DiffuseColor