From a18b5398de42190e42699ac3d2e91274ef0c22db Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Thu, 7 May 2026 06:52:14 -0400 Subject: [PATCH] fix(io): remove zero-sweep arcs during DXF import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DXF files can contain degenerate arcs where start angle equals end angle (zero sweep), often left as construction artifacts by CAD software. These create spurious shapes in ShapeBuilder — e.g. SULLYS-033.dxf showed 5 loops instead of 4 (3 cutouts + perimeter). Co-Authored-By: Claude Opus 4.6 --- OpenNest.IO/CadImporter.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/OpenNest.IO/CadImporter.cs b/OpenNest.IO/CadImporter.cs index 75f049a..edf806c 100644 --- a/OpenNest.IO/CadImporter.cs +++ b/OpenNest.IO/CadImporter.cs @@ -27,6 +27,7 @@ namespace OpenNest.IO var dxf = Dxf.Import(path); RemoveDuplicateArcs(dxf.Entities); + RemoveZeroSweepArcs(dxf.Entities); var bends = new List(); if (options.DetectBends && dxf.Document != null) @@ -156,6 +157,12 @@ namespace OpenNest.IO return drawing; } + internal static void RemoveZeroSweepArcs(List entities) + { + entities.RemoveAll(e => + e is Arc arc && arc.StartAngle.IsEqualTo(arc.EndAngle, Tolerance.ChainTolerance)); + } + internal static void RemoveDuplicateArcs(List entities) { var circles = entities.OfType().ToList();