From 3f557dd48d3bc7935d6d6471a97dd157c1051fb6 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Fri, 18 Feb 2022 10:18:10 -0600 Subject: [PATCH 1/2] fix ordering of edges in loop generation --- src/Mod/Path/PathCommands.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/Path/PathCommands.py b/src/Mod/Path/PathCommands.py index 726166ae78..725f27bf27 100644 --- a/src/Mod/Path/PathCommands.py +++ b/src/Mod/Path/PathCommands.py @@ -108,8 +108,8 @@ class _CommandSelectLoop: if loopwire: FreeCADGui.Selection.clearSelection() elist = obj.Shape.Edges - for e in elist: - for i in loopwire.Edges: + for i in loopwire.Edges: + for e in elist: if e.hashCode() == i.hashCode(): FreeCADGui.Selection.addSelection( obj, "Edge" + str(elist.index(e) + 1) From 67c0336fa2dd2acdbe6163d74625c70e2f65d204 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Fri, 18 Feb 2022 10:19:26 -0600 Subject: [PATCH 2/2] [Path] Fix Path generation for forking wires --- src/Mod/Path/PathScripts/PathEngraveBase.py | 14 +++++++++++--- src/Mod/Path/PathScripts/PathOpTools.py | 9 ++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathEngraveBase.py b/src/Mod/Path/PathScripts/PathEngraveBase.py index fab2c1dfaf..71810d1fb3 100644 --- a/src/Mod/Path/PathScripts/PathEngraveBase.py +++ b/src/Mod/Path/PathScripts/PathEngraveBase.py @@ -63,15 +63,23 @@ class ObjectOp(PathOp.ObjectOp): """buildpathocc(obj, wires, zValues, relZ=False) ... internal helper function to generate engraving commands.""" PathLog.track(obj.Label, len(wires), zValues) + decomposewires = [] for wire in wires: - offset = wire + decomposewires.extend(PathOpTools.makeWires(wire.Edges)) + + wires = decomposewires + for wire in wires: + # offset = wire # reorder the wire if hasattr(obj, "StartVertex"): start_idx = obj.StartVertex + edges = wire.Edges - edges = copy.copy(PathOpTools.orientWire(offset, forward).Edges) - edges = Part.sortEdges(edges)[0] + # edges = copy.copy(PathOpTools.orientWire(offset, forward).Edges) + # PathLog.track("wire: {} offset: {}".format(len(wire.Edges), len(edges))) + # edges = Part.sortEdges(edges)[0] + # PathLog.track("edges: {}".format(len(edges))) last = None diff --git a/src/Mod/Path/PathScripts/PathOpTools.py b/src/Mod/Path/PathScripts/PathOpTools.py index 9cad4ca3a7..290e62ef9a 100644 --- a/src/Mod/Path/PathScripts/PathOpTools.py +++ b/src/Mod/Path/PathScripts/PathOpTools.py @@ -82,6 +82,13 @@ def debugEdge(label, e): ) +def makeWires(inEdges): + """makeWires ... function to make non-forking wires from a collection of edges""" + edgelists = Part.sortEdges(inEdges) + result = [Part.Wire(e) for e in edgelists] + return result + + def debugWire(label, w): """debugWire(label, w) ... prints python statements for all edges of w to be added to the object tree in a group.""" if not PrintWireDebug: @@ -160,7 +167,7 @@ def orientWire(w, forward=True): If forward = True (the default) the wire is oriented clockwise, looking down the negative Z axis. If forward = False the wire is oriented counter clockwise. If forward = None the orientation is determined by the order in which the edges appear in the wire.""" - PathLog.debug("orienting forward: {}".format(forward)) + PathLog.debug("orienting forward: {}: {} edges".format(forward, len(w.Edges))) wire = Part.Wire(_orientEdges(w.Edges)) if forward is not None: if forward != _isWireClockwise(wire):