From 3e39a01312eba056fea361fb45f7250cc86476a8 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Mon, 7 Jul 2025 17:02:14 +0200 Subject: [PATCH] Draft: make_sketch.py should not use view direction (#22249) --- src/Mod/Draft/draftmake/make_sketch.py | 30 +++++++++++--------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/Mod/Draft/draftmake/make_sketch.py b/src/Mod/Draft/draftmake/make_sketch.py index ea055e9924..3f958bbccc 100644 --- a/src/Mod/Draft/draftmake/make_sketch.py +++ b/src/Mod/Draft/draftmake/make_sketch.py @@ -78,11 +78,6 @@ def make_sketch(objects_list, autoconstraints=False, addTo=None, import Part from Sketcher import Constraint - if App.GuiUp: - v_dir = gui_utils.get_3d_view().getViewDirection() - else: - v_dir = App.Vector(0, 0, -1) - # lists to accumulate shapes with defined normal and undefined normal shape_norm_yes = list() shape_norm_no = list() @@ -127,21 +122,20 @@ def make_sketch(objects_list, autoconstraints=False, addTo=None, # suppose all geometries are straight lines or points points = [vertex.Point for shape in shapes_list for vertex in shape.Vertexes] if len(points) >= 2: - poly = Part.makePolygon(points) - if not DraftGeomUtils.is_planar(poly, tol): - App.Console.PrintError(translate("draft", - "All Shapes must be coplanar") + "\n") - return None - normal = DraftGeomUtils.get_normal(poly, tol) - if not normal: - # all points aligned - poly_dir = poly.Edges[0].Curve.Direction - normal = (v_dir - v_dir.dot(poly_dir)*poly_dir).normalize() - normal = normal.negative() + try: + poly = Part.makePolygon(points) + except Part.OCCError: + # all points coincide + normal = App.Vector(0, 0, 1) + else: + if not DraftGeomUtils.is_planar(poly, tol): + App.Console.PrintError(translate("draft", + "All Shapes must be coplanar") + "\n") + return None + normal = DraftGeomUtils.get_shape_normal(poly) else: # only one point - normal = v_dir.negative() - + normal = App.Vector(0, 0, 1) if addTo: nobj = addTo