mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-24 17:11:06 -04:00
A BOM row with a file name and a matching drawing but a blank thickness was reported "No DXF" and locked, so its thickness could not be entered and the part was dropped: BomAnalyzer skips such items before looking for a drawing, and the form only knew drawings the analyzer matched. A row with a blank material read "Matched" but was silently left out of every group. Rows now resolve their drawing through a DrawingFileIndex shared with BomAnalyzer (whose behavior and tests are unchanged), and a row's status is computed from its values: Ready | Needs material | Needs thickness | No drawing found | No file name Rows with a drawing stay editable, and an edit updates the status cell. Groups take only Ready rows (a zero, negative or non-finite thickness is not Ready). The summary line counts ready rows and each problem. Build_RowWithoutThickness_StillFindsItsDrawing failed at its DxfPath assertion against the previous commit. Mutation reds: removing the material check, accepting zero or non-finite thickness, skipping the drawing for rows without thickness, and grouping without the status each fail the Bom tests. Project Memory: b8e3a978-2cfe-4fe7-b2a5-eb01c6c54679
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
|
|
namespace OpenNest.IO.Bom;
|
|
|
|
/// <summary>
|
|
/// Builds the import dialog's part rows from the BOM items and the drawing
|
|
/// folder.
|
|
/// </summary>
|
|
public static class BomImportRows
|
|
{
|
|
/// <summary>
|
|
/// Returns one row per BOM item, in BOM order. Every row with a file
|
|
/// name gets the drawing it matches in <paramref name="dxfFolder"/>,
|
|
/// whether or not its material and thickness are filled in.
|
|
/// </summary>
|
|
public static List<BomPartRow> Build(List<BomItem> items, string dxfFolder)
|
|
{
|
|
var index = DrawingFileIndex.Load(dxfFolder);
|
|
var rows = new List<BomPartRow>();
|
|
|
|
foreach (var item in items)
|
|
{
|
|
rows.Add(
|
|
new BomPartRow
|
|
{
|
|
ItemNum = item.ItemNum,
|
|
FileName = item.FileName,
|
|
Qty = item.Qty,
|
|
Description = item.Description,
|
|
Material = item.Material,
|
|
Thickness = item.Thickness,
|
|
DxfPath = string.IsNullOrWhiteSpace(item.FileName)
|
|
? null
|
|
: index.Find(item.FileName),
|
|
}
|
|
);
|
|
}
|
|
|
|
return rows;
|
|
}
|
|
}
|