feat: add CadImporter.ImportDrawing convenience method
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -48,6 +48,23 @@ namespace OpenNest.IO
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Convenience for headless callers: Import a file and build a Drawing
|
||||||
|
/// in a single call, using all loaded entities and detected bends.
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Build a fully-populated <see cref="Drawing"/> from an import result plus
|
/// Build a fully-populated <see cref="Drawing"/> from an import result plus
|
||||||
/// the caller's current entity and bend state. UI callers pass the currently
|
/// the caller's current entity and bend state. UI callers pass the currently
|
||||||
|
|||||||
@@ -108,5 +108,19 @@ namespace OpenNest.Tests.IO
|
|||||||
|
|
||||||
Assert.Same(edited, drawing.Program);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user