diff --git a/OpenNest.IO/CadImporter.cs b/OpenNest.IO/CadImporter.cs
index bbfda92..ef989e9 100644
--- a/OpenNest.IO/CadImporter.cs
+++ b/OpenNest.IO/CadImporter.cs
@@ -48,6 +48,23 @@ namespace OpenNest.IO
};
}
+ ///
+ /// Convenience for headless callers: Import a file and build a Drawing
+ /// in a single call, using all loaded entities and detected bends.
+ ///
+ public static Drawing ImportDrawing(string path, CadImportOptions options = null)
+ {
+ options ??= CadImportOptions.Default;
+ var result = Import(path, options);
+ return BuildDrawing(
+ result,
+ result.Entities,
+ result.Bends,
+ options.Quantity,
+ options.Customer,
+ editedProgram: null);
+ }
+
///
/// Build a fully-populated from an import result plus
/// the caller's current entity and bend state. UI callers pass the currently
diff --git a/OpenNest.Tests/IO/CadImporterTests.cs b/OpenNest.Tests/IO/CadImporterTests.cs
index c7d55d2..7a52338 100644
--- a/OpenNest.Tests/IO/CadImporterTests.cs
+++ b/OpenNest.Tests/IO/CadImporterTests.cs
@@ -108,5 +108,19 @@ namespace OpenNest.Tests.IO
Assert.Same(edited, drawing.Program);
}
+
+ [Fact]
+ public void ImportDrawing_ComposesImportAndBuild()
+ {
+ var drawing = CadImporter.ImportDrawing(TestDxf,
+ new CadImportOptions { Quantity = 3, Customer = "ACME" });
+
+ Assert.NotNull(drawing);
+ Assert.Equal("4526 A14 PT11", drawing.Name);
+ Assert.Equal(3, drawing.Quantity.Required);
+ Assert.Equal("ACME", drawing.Customer);
+ Assert.NotNull(drawing.Program);
+ Assert.NotNull(drawing.SourceEntities);
+ }
}
}