Draft: fix axis calculation in make_sketch

Fixes #18713.

The code follows the suggestion by imm/webmite:
https://forum.freecad.org/viewtopic.php?p=799014#p799014

@webmite Thank you.
This commit is contained in:
Roy-043
2025-01-08 17:50:02 +01:00
committed by Yorik van Havre
parent c420316903
commit 3b258b6178

View File

@@ -176,7 +176,13 @@ def make_sketch(objects_list, autoconstraints=False, addTo=None,
axis = App.Vector(0, 0, 1).cross(normal)
angle = DraftVecUtils.angle(normal, App.Vector(0, 0, 1)) * App.Units.Radian
if axis.Length > 1e-6:
axis.normalize()
elif normal.z >= 0:
axis = App.Vector(0, 0, 1)
else:
axis = App.Vector(0, 0, -1)
angle = math.degrees(DraftVecUtils.angle(normal, App.Vector(0, 0, 1)))
rotation = App.Rotation(axis, angle)
point = shapes_list[0].Vertexes[0].Point