From 1a2cd1befcdcc50766b0de7478f681bd5c2449c9 Mon Sep 17 00:00:00 2001 From: Furgo <148809153+furgo16@users.noreply.github.com> Date: Wed, 10 Sep 2025 17:12:40 +0200 Subject: [PATCH] BIM: Fix inverted cut direction for rotated SectionPlane Rotating an ArchSectionPlane object caused its cutting effect to flip, affecting both the live `CutView` and 2D projections. The `_SectionPlane.execute()` method incorrectly tried to auto-correct the orientation of a temporary plane before applying the object's final placement. The fix refactors this to a "transform-then-verify" pattern: the object's full `Placement` is now applied to the temporary plane first, and only then is the resulting face's actual normal validated against the intended normal from the `Placement`. This ensures the `Shape` is always geometrically consistent with the `Placement`, making the cut direction predictable at all angles. --- src/Mod/BIM/ArchSectionPlane.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Mod/BIM/ArchSectionPlane.py b/src/Mod/BIM/ArchSectionPlane.py index a6cfe18591..065c77acbb 100644 --- a/src/Mod/BIM/ArchSectionPlane.py +++ b/src/Mod/BIM/ArchSectionPlane.py @@ -848,7 +848,7 @@ class _SectionPlane: self.setProperties(obj) def execute(self,obj): - + import math import Part l = 1 h = 1 @@ -866,9 +866,14 @@ class _SectionPlane: h = 1 p = Part.makePlane(l,h,Vector(l/2,-h/2,0),Vector(0,0,-1)) # make sure the normal direction is pointing outwards, you never know what OCC will decide... - if p.normalAt(0,0).getAngle(obj.Placement.Rotation.multVec(FreeCAD.Vector(0,0,1))) > 1: - p.reverse() + # Apply the object's placement to the new plane first. p.Placement = obj.Placement + + # Now, check if the resulting plane's normal matches the placement's intended direction. + # This robustly handles all rotation angles and potential OCC inconsistencies. + target_normal = obj.Placement.Rotation.multVec(FreeCAD.Vector(0,0,1)) + if p.normalAt(0,0).getAngle(target_normal) > math.pi / 2: + p.reverse() obj.Shape = p self.svgcache = None self.shapecache = None