From 063f05c72d1272107818526e5397ad3d17604782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= Date: Sun, 27 Jun 2021 22:34:35 +0200 Subject: [PATCH] Arch: Align profile's Y with layout's normal vector Align profile's Y axis with lyouts normal vector so the profile is always upright regardles of the direction of extrusion. See [1] for more details. [1] https://forum.freecadweb.org/viewtopic.php?f=3&t=59725 --- src/Mod/Arch/ArchFrame.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Mod/Arch/ArchFrame.py b/src/Mod/Arch/ArchFrame.py index 1fee9e3a70..388b9f2973 100644 --- a/src/Mod/Arch/ArchFrame.py +++ b/src/Mod/Arch/ArchFrame.py @@ -219,12 +219,20 @@ class _Frame(ArchComponent.Component): basepoint = profile.CenterOfMass profile.translate(bpoint.sub(basepoint)) if obj.Align: + # Align profile's Z axis with the direction of the layout edge. axis = profile.Placement.Rotation.multVec(FreeCAD.Vector(0,0,1)) angle = bvec.getAngle(axis) if round(angle,Draft.precision()) != 0: if round(angle,Draft.precision()) != round(math.pi,Draft.precision()): rotaxis = axis.cross(bvec) profile.rotate(DraftVecUtils.tup(bpoint), DraftVecUtils.tup(rotaxis), math.degrees(angle)) + # Align profile's Y axis with layouts normal vecror. + axis = profile.Placement.Rotation.multVec(FreeCAD.Vector(0,1,0)) + angle = normal.getAngle(axis) + if round(angle,Draft.precision()) != 0: + if round(angle,Draft.precision()) != round(math.pi,Draft.precision()): + rotaxis = axis.cross(normal) + profile.rotate(DraftVecUtils.tup(bpoint), DraftVecUtils.tup(rotaxis), math.degrees(angle)) if obj.Rotation: profile.rotate(DraftVecUtils.tup(bpoint), DraftVecUtils.tup(FreeCAD.Vector(bvec).normalize()), obj.Rotation) #profile = wire.makePipeShell([profile],True,False,2) TODO buggy