From 87b965f8954f5e4fc72dcfb5a6d930bef741afb8 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Fri, 10 Apr 2026 14:11:49 -0400 Subject: [PATCH] refactor(ui): use CadImporter in BomImportForm Replaces the hand-rolled DXF->Drawing pipeline (Dxf.Import + bend detection + normalize + ConvertGeometry + pierce offset extraction) with a single CadImporter.ImportDrawing call. Brings BomImportForm's output in line with the rest of the callers: drawings now carry Source.Offset, SourceEntities, SuppressedEntityIds, and detected bends, and round-trip cleanly through nest files. Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest/Forms/BomImportForm.cs | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/OpenNest/Forms/BomImportForm.cs b/OpenNest/Forms/BomImportForm.cs index 5aaf0ae..60fbca0 100644 --- a/OpenNest/Forms/BomImportForm.cs +++ b/OpenNest/Forms/BomImportForm.cs @@ -1,9 +1,5 @@ -using OpenNest.Bending; -using OpenNest.CNC; -using OpenNest.Converters; using OpenNest.Geometry; using OpenNest.IO; -using OpenNest.IO.Bending; using OpenNest.IO.Bom; using System; using System.Collections.Generic; @@ -470,33 +466,9 @@ namespace OpenNest.Forms try { - var result = Dxf.Import(part.DxfPath); - - var bends = new List(); - if (result.Document != null) - bends = BendDetectorRegistry.AutoDetect(result.Document); - Bend.UpdateEtchEntities(result.Entities, bends); - - var drawingName = Path.GetFileNameWithoutExtension(part.DxfPath); - var drawing = new Drawing(drawingName); - drawing.Color = Drawing.GetNextColor(); - drawing.Source.Path = part.DxfPath; - drawing.Quantity.Required = part.Qty ?? 1; + var drawing = CadImporter.ImportDrawing(part.DxfPath, + new CadImportOptions { Quantity = part.Qty ?? 1 }); drawing.Material = new Material(material); - if (bends.Count > 0) - drawing.Bends.AddRange(bends); - - var normalized = ShapeProfile.NormalizeEntities(result.Entities); - var pgm = ConvertGeometry.ToProgram(normalized); - - if (pgm.Codes.Count > 0 && pgm[0].Type == CodeType.RapidMove) - { - var rapid = (RapidMove)pgm[0]; - drawing.Source.Offset = rapid.EndPoint; - pgm.Offset(-rapid.EndPoint); - } - - drawing.Program = pgm; nest.Drawings.Add(drawing); } catch (Exception ex)