From fa80866a0ebc09f4de78e4df777aa6ba6795b754 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Fri, 15 Oct 2021 22:11:40 +0200 Subject: [PATCH 1/2] Daft: fix cleanProjection (used by Draft_Shape2DView and DXF export) --- src/Mod/Draft/draftgeoutils/wires.py | 59 +++++++++------------------- 1 file changed, 19 insertions(+), 40 deletions(-) diff --git a/src/Mod/Draft/draftgeoutils/wires.py b/src/Mod/Draft/draftgeoutils/wires.py index 394ce8005269..763dbb6ce46b 100644 --- a/src/Mod/Draft/draftgeoutils/wires.py +++ b/src/Mod/Draft/draftgeoutils/wires.py @@ -354,56 +354,35 @@ def getvec(v1, v2): def cleanProjection(shape, tessellate=True, seglength=0.05): - """Return a valid compound of edges, by recreating them. + """Return a compound of edges, optionally tesselate ellipses, splines + and bezcurves. - This is because the projection algorithm somehow creates wrong shapes. - They display fine, but on loading the file the shape is invalid. - - Now with tanderson's fix to `ProjectionAlgos`, that isn't the case, - but this function can be used for tessellating ellipses and splines - for DXF output-DF. + The function was formerly used to workaround bugs in the projection + algorithm. These bugs have since been fixed. Now the function is only + used when tessalation of ellipses, splines and bezcurves is required + (DXF output and Draft_Shape2DView). """ oldedges = shape.Edges newedges = [] for e in oldedges: + typ = geomType(e) try: - if geomType(e) == "Line": - newedges.append(e.Curve.toShape()) - - elif geomType(e) == "Circle": - if len(e.Vertexes) > 1: - mp = findMidpoint(e) - a = Part.Arc(e.Vertexes[0].Point, - mp, - e.Vertexes[-1].Point).toShape() - newedges.append(a) - else: - newedges.append(e.Curve.toShape()) - - elif geomType(e) == "Ellipse": + if typ in ["Line", "Circle"]: + newedges.append(e) + elif typ == "Ellipse": if tessellate: newedges.append(Part.Wire(curvetowire(e, seglength))) else: - if len(e.Vertexes) > 1: - a = Part.Arc(e.Curve, - e.FirstParameter, - e.LastParameter).toShape() - newedges.append(a) - else: - newedges.append(e.Curve.toShape()) - - elif (geomType(e) == "BSplineCurve" - or geomType(e) == "BezierCurve"): - if tessellate: + newedges.append(e) + elif typ in ["BSplineCurve", "BezierCurve"]: + if isLine(e.Curve): + line = Part.LineSegment(e.Vertexes[0].Point, + e.Vertexes[-1].Point) + newedges.append(line) + elif tessellate: newedges.append(Part.Wire(curvetowire(e, seglength))) else: - if isLine(e.Curve): - line = Part.LineSegment(e.Vertexes[0].Point, - e.Vertexes[-1].Point).toShape() - newedges.append(line) - else: - newedges.append(e.Curve.toShape(e.FirstParameter, - e.LastParameter)) + newedges.append(e) else: newedges.append(e) except Part.OCCError: @@ -527,4 +506,4 @@ def get_extended_wire(wire, offset_start, offset_end): wire = Part.Wire(wire.OrderedEdges + [new_edge]) return wire -## @} \ No newline at end of file +## @} From 7da42730e115146479aef4806be2aeb363a42dc9 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Fri, 15 Oct 2021 22:18:17 +0200 Subject: [PATCH 2/2] Update wires.py typo --- src/Mod/Draft/draftgeoutils/wires.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftgeoutils/wires.py b/src/Mod/Draft/draftgeoutils/wires.py index 763dbb6ce46b..fabc5c26015b 100644 --- a/src/Mod/Draft/draftgeoutils/wires.py +++ b/src/Mod/Draft/draftgeoutils/wires.py @@ -359,7 +359,7 @@ def cleanProjection(shape, tessellate=True, seglength=0.05): The function was formerly used to workaround bugs in the projection algorithm. These bugs have since been fixed. Now the function is only - used when tessalation of ellipses, splines and bezcurves is required + used when tessellation of ellipses, splines and bezcurves is required (DXF output and Draft_Shape2DView). """ oldedges = shape.Edges