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.
This commit is contained in:
Furgo
2025-09-10 17:12:40 +02:00
committed by Yorik van Havre
parent 0c71c05c06
commit 1a2cd1befc

View File

@@ -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