diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 87b4b79d6d..e3a5f8ca2e 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -2720,33 +2720,32 @@ def makeSketch(objectslist,autoconstraints=False,addTo=None, closed = obj.Closed if len(obj.Shape.Vertexes) < 3: - FreeCAD.Console.PrintError(translate("draft","Need at least 3 points in order to convert to Sketch")) - return None - - # Use the first three points to make a working plane. We've already - # checked to make sure everything is coplanar - plane = Part.Plane(*[i.Point for i in obj.Shape.Vertexes[:3]]) - normal = plane.Axis - - if rotation is None: - axis = FreeCAD.Vector(0,0,1).cross(normal) - angle = DraftVecUtils.angle(normal, FreeCAD.Vector(0,0,1)) * FreeCAD.Units.Radian - rotation = FreeCAD.Rotation(axis, angle) - for edge in obj.Shape.Edges: - # edge.rotate(FreeCAD.Vector(0,0,0), rotAxis, rotAngle) - edge = DraftGeomUtils.orientEdge(edge, normal) - nobj.addGeometry(edge) - if autoconstraints: - last = nobj.GeometryCount - segs = list(range(last-len(obj.Shape.Edges),last-1)) - for seg in segs: - constraints.append(Constraint("Coincident",seg,EndPoint,seg+1,StartPoint)) - if DraftGeomUtils.isAligned(nobj.Geometry[seg],"x"): - constraints.append(Constraint("Vertical",seg)) - elif DraftGeomUtils.isAligned(nobj.Geometry[seg],"y"): - constraints.append(Constraint("Horizontal",seg)) - if closed: - constraints.append(Constraint("Coincident",last-1,EndPoint,segs[0],StartPoint)) + e = obj.Shape.Edges[0] + nobj.addGeometry(Part.LineSegment(e.Curve,e.FirstParameter,e.LastParameter)) + else: + # Use the first three points to make a working plane. We've already + # checked to make sure everything is coplanar + plane = Part.Plane(*[i.Point for i in obj.Shape.Vertexes[:3]]) + normal = plane.Axis + if rotation is None: + axis = FreeCAD.Vector(0,0,1).cross(normal) + angle = DraftVecUtils.angle(normal, FreeCAD.Vector(0,0,1)) * FreeCAD.Units.Radian + rotation = FreeCAD.Rotation(axis, angle) + for edge in obj.Shape.Edges: + # edge.rotate(FreeCAD.Vector(0,0,0), rotAxis, rotAngle) + edge = DraftGeomUtils.orientEdge(edge, normal) + nobj.addGeometry(edge) + if autoconstraints: + last = nobj.GeometryCount + segs = list(range(last-len(obj.Shape.Edges),last-1)) + for seg in segs: + constraints.append(Constraint("Coincident",seg,EndPoint,seg+1,StartPoint)) + if DraftGeomUtils.isAligned(nobj.Geometry[seg],"x"): + constraints.append(Constraint("Vertical",seg)) + elif DraftGeomUtils.isAligned(nobj.Geometry[seg],"y"): + constraints.append(Constraint("Horizontal",seg)) + if closed: + constraints.append(Constraint("Coincident",last-1,EndPoint,segs[0],StartPoint)) ok = True elif tp == "BSpline": nobj.addGeometry(obj.Shape.Edges[0].Curve)