From 8a739ad5b77e874035a82e8881406bcb1eeedf4a Mon Sep 17 00:00:00 2001 From: Furgo <148809153+furgo16@users.noreply.github.com> Date: Wed, 14 Jan 2026 15:42:05 +0100 Subject: [PATCH] BIM: provide better user information when a face horizontality or verticality cannot be determined (#26231) * BIM: pinpoint failing face for ArchComponent.isVertical() * BIM: pass face index when checking for verticality * BIM: keep old comment Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com> --------- Co-authored-by: Roy-043 <70520633+Roy-043@users.noreply.github.com> --- src/Mod/BIM/ArchComponent.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Mod/BIM/ArchComponent.py b/src/Mod/BIM/ArchComponent.py index f753ba3934..961c91bae0 100644 --- a/src/Mod/BIM/ArchComponent.py +++ b/src/Mod/BIM/ArchComponent.py @@ -1341,13 +1341,21 @@ class AreaCalculator: for prop in ["VerticalArea", "HorizontalArea", "PerimeterLength"]: setattr(self.obj, prop, 0) - def isFaceVertical(self, face): + def isFaceVertical(self, face, face_index=None): """Determine if a face is vertical. A face is considered vertical if: - Its normal vector forms an angle close to 90 degrees with the Z-axis. - The projected face has an area of zero. + Parameters + ---------- + face : Part.Face + The face object to be checked. + face_index : str, optional + The face's 1-based index identifier, used for debugging error messages. + Defaults to None. + Notes ----- The check whether the projected face has an area of zero means that roof-like @@ -1360,6 +1368,8 @@ class AreaCalculator: import DraftGeomUtils import TechDraw + face_name = f" Face{face_index}" if face_index is not None else "" + if face.Surface.TypeId == "Part::GeomCylinder": angle = face.Surface.Axis.getAngle(FreeCAD.Vector(0, 0, 1)) return self.isZeroAngle(angle) @@ -1380,7 +1390,7 @@ class AreaCalculator: projectedArea = Part.Face(wires).Area except Part.OCCError: FreeCAD.Console.PrintWarning( - translate("Arch", f"Could not project face from {self.obj.Label}\n") + translate("Arch", f"Could not project face{face_name} from {self.obj.Label}\n") ) return False @@ -1391,7 +1401,7 @@ class AreaCalculator: FreeCAD.Console.PrintWarning( translate( "Arch", - f"Could not determine if a face from {self.obj.Label}" + f"Could not determine if face{face_name} from {self.obj.Label}" " is vertical: normalAt() failed\n", ) ) @@ -1429,8 +1439,8 @@ class AreaCalculator: horizontalAreaFaces = [] # Compute vertical area and collect faces to be projected for the horizontal area - for face in self.obj.Shape.Faces: - if self.isFaceVertical(face): + for i, face in enumerate(self.obj.Shape.Faces, start=1): + if self.isFaceVertical(face, face_index=i): verticalArea += face.Area else: horizontalAreaFaces.append(face)