refactor(console): use CadImporter for DXF import

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-10 13:03:16 -04:00
parent 399f8dda6e
commit 0f5aace126

View File

@@ -1,5 +1,4 @@
using OpenNest;
using OpenNest.Converters;
using OpenNest.Geometry;
using OpenNest.IO;
using System;
@@ -241,25 +240,15 @@ static class NestConsole
static Drawing ImportDxf(string path)
{
var geometry = Dxf.GetGeometry(path);
if (geometry.Count == 0)
try
{
Console.Error.WriteLine($"Error: failed to read DXF file or no geometry found: {path}");
return CadImporter.ImportDrawing(path);
}
catch (System.Exception ex)
{
Console.Error.WriteLine($"Error: failed to import DXF '{path}': {ex.Message}");
return null;
}
var normalized = ShapeProfile.NormalizeEntities(geometry);
var pgm = ConvertGeometry.ToProgram(normalized);
if (pgm == null)
{
Console.Error.WriteLine($"Error: failed to convert geometry: {path}");
return null;
}
var name = Path.GetFileNameWithoutExtension(path);
return new Drawing(name, pgm);
}
static void ApplyTemplate(Plate plate, Options options)