feat(io): add DWG file import support via ACadSharp DwgReader

ACadSharp already includes DwgReader, so this wires it up across the
entire import pipeline — Dxf.Import, CadConverter drag-drop, nest
import dialog, console CLI, BOM analyzer, and training data collector.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-27 22:58:26 -04:00
parent 9d58e6fba8
commit 1c994718fb
7 changed files with 39 additions and 14 deletions
+19 -4
View File
@@ -27,8 +27,7 @@ namespace OpenNest.IO
/// </summary>
public static DxfImportResult Import(string path)
{
using var reader = new DxfReader(path);
var doc = reader.Read();
var doc = ReadDocument(path);
return new DxfImportResult
{
@@ -41,8 +40,7 @@ namespace OpenNest.IO
{
try
{
using var reader = new DxfReader(path);
var doc = reader.Read();
var doc = ReadDocument(path);
return ConvertEntities(doc);
}
catch (Exception ex)
@@ -113,6 +111,23 @@ namespace OpenNest.IO
#region Private
private static bool IsDwg(string path) =>
Path.GetExtension(path).Equals(".dwg", StringComparison.OrdinalIgnoreCase);
private static CadDocument ReadDocument(string path)
{
if (IsDwg(path))
{
using var reader = new DwgReader(path);
return reader.Read();
}
else
{
using var reader = new DxfReader(path);
return reader.Read();
}
}
private static List<Entity> ConvertEntities(CadDocument doc)
{
var entities = new List<Entity>();