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
This commit is contained in:
Łukasz Stelmach
2021-06-27 22:34:35 +02:00
parent 79b41f7393
commit a92ee7f358

View File

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