fix(core): keep cut-offs in their cut sequence through regenerate and save

A cut-off's place in Plate.Parts is its cut sequence number, but
RegenerateCutOffs removed every cut-off part and appended it again, so
any part drag, fill or cut-off move sent the cut-offs to the end. The
nest file didn't store the position either, so reopening did the same.

RegenerateCutOffs now puts each cut-off back at its previous index (new
cut-offs go at the end), and CutOffDto.Sequence saves the index. Older
files without it load the cut-offs at the end, as before.
This commit is contained in:
aj
2026-09-28 18:44:04 -04:00
parent 6803d7519f
commit 4da48eed68
6 changed files with 182 additions and 7 deletions
+11
View File
@@ -223,6 +223,16 @@ namespace OpenNest.IO
var cutoffs = new List<CutOffDto>();
foreach (var cutoff in plate.CutOffs)
{
var sequence = -1;
for (var j = 0; j < plate.Parts.Count; j++)
{
if (ReferenceEquals(plate.Parts[j].BaseDrawing, cutoff.Drawing))
{
sequence = j;
break;
}
}
cutoffs.Add(
new CutOffDto
{
@@ -231,6 +241,7 @@ namespace OpenNest.IO
Axis = cutoff.Axis == CutOffAxis.Vertical ? "vertical" : "horizontal",
StartLimit = cutoff.StartLimit,
EndLimit = cutoff.EndLimit,
Sequence = sequence >= 0 ? sequence : null,
}
);
}