CAM: sort tool paths for Engrave and Deburr operation (#21531)

Co-authored-by: jffmichi <>
This commit is contained in:
jffmichi
2025-06-23 17:22:21 +02:00
committed by GitHub
parent f66c2a27f2
commit 67efd9eff3

View File

@@ -24,6 +24,7 @@ from lazy_loader.lazy_loader import LazyLoader
import Path
import Path.Op.Base as PathOp
import Path.Op.Util as PathOpUtil
import PathScripts.PathUtils as PathUtils
import copy
__doc__ = "Base class for all ops in the engrave family."
@@ -61,6 +62,15 @@ class ObjectOp(PathOp.ObjectOp):
"""buildpathocc(obj, wires, zValues, relZ=False) ... internal helper function to generate engraving commands."""
Path.Log.track(obj.Label, len(wires), zValues)
# sort wires, adapted from Area.py
if len(wires) > 1:
locations = []
for w in wires:
locations.append({"x": w.BoundBox.Center.x, "y": w.BoundBox.Center.y, "wire": w})
locations = PathUtils.sort_locations(locations, ["x", "y"])
wires = [j["wire"] for j in locations]
decomposewires = []
for wire in wires:
decomposewires.extend(PathOpUtil.makeWires(wire.Edges))