feat: add DxfImporter.Import returning entities + CadDocument

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-24 20:23:53 -04:00
parent dd2892a9fe
commit 574a8f2c38
2 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
using ACadSharp;
using OpenNest.Geometry;
using System.Collections.Generic;
namespace OpenNest.IO
{
public class DxfImportResult
{
public List<Entity> Entities { get; set; } = new();
public CadDocument Document { get; set; }
}
}

View File

@@ -65,6 +65,24 @@ namespace OpenNest.IO
return entities;
}
/// <summary>
/// Imports a DXF file, returning both converted entities and the raw CadDocument
/// for bend detection. The CadDocument is NOT disposed — caller can use it for
/// additional analysis (e.g., MText extraction for bend notes).
/// </summary>
public DxfImportResult Import(string path)
{
using var reader = new DxfReader(path);
var doc = reader.Read();
var entities = GetGeometry(doc);
return new DxfImportResult
{
Entities = entities,
Document = doc
};
}
public bool GetGeometry(Stream stream, out List<Entity> geometry)
{
var success = false;