From 0a47b6da2617eebc4faa4a39ec2ae52e73fddb46 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Tue, 2 Sep 2025 10:49:48 +0200 Subject: [PATCH] BIM: fix Arch_Reference colors --- src/Mod/BIM/ArchReference.py | 174 ++++++++++++++++++++++++----------- 1 file changed, 120 insertions(+), 54 deletions(-) diff --git a/src/Mod/BIM/ArchReference.py b/src/Mod/BIM/ArchReference.py index 17213405b3..1c05863272 100644 --- a/src/Mod/BIM/ArchReference.py +++ b/src/Mod/BIM/ArchReference.py @@ -36,6 +36,7 @@ __url__ = "https://www.freecad.org" import os import re +import struct import zipfile import FreeCAD @@ -147,6 +148,7 @@ class ArchReference: if filename.lower().endswith(".fcstd"): zdoc = zipfile.ZipFile(filename) if zdoc: + self.shapes = [] if obj.Part: if obj.Part in self.parts: if self.parts[obj.Part][1] in zdoc.namelist(): @@ -155,6 +157,7 @@ class ArchReference: f.close() shapedata = shapedata.decode("utf8") shape = self.cleanShape(shapedata,obj,self.parts[obj.Part][2]) + self.shapes.append(shape) obj.Shape = shape if not pl.isIdentity(): obj.Placement = pl @@ -162,16 +165,15 @@ class ArchReference: t = translate("Arch","Part not found in file") FreeCAD.Console.PrintError(t+"\n") else: - shapes = [] for part in self.parts.values(): f = zdoc.open(part[1]) shapedata = f.read() f.close() shapedata = shapedata.decode("utf8") shape = self.cleanShape(shapedata,obj) - shapes.append(shape) - if shapes: - obj.Shape = Part.makeCompound(shapes) + self.shapes.append(shape) + if self.shapes: + obj.Shape = Part.makeCompound(self.shapes) elif filename.lower().endswith(".ifc"): ifcfile = self.getIfcFile(filename) if not ifcfile: @@ -447,48 +449,123 @@ class ArchReference: def getColors(self, obj): - """returns the DiffuseColor of the referenced object""" + """returns the Shape Appearance of the referenced object(s)""" filename = self.getFile(obj) if not filename: - return None - part = obj.Part - if not obj.Part: - return None - colors = None - if filename.lower().endswith(".fcstd"): - zdoc = zipfile.ZipFile(filename) - if not "GuiDocument.xml" in zdoc.namelist(): - return None - colorfile = None - with zdoc.open("GuiDocument.xml") as docf: - writemode1 = False - writemode2 = False - for line in docf: - line = line.decode("utf8") - if ("