feat: add DxfImporter.Import returning entities + CadDocument
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -65,6 +65,24 @@ namespace OpenNest.IO
|
|||||||
return entities;
|
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)
|
public bool GetGeometry(Stream stream, out List<Entity> geometry)
|
||||||
{
|
{
|
||||||
var success = false;
|
var success = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user