fix: preserve leading rapid in programs to prevent missing contour segment

The CAD converter and BOM import were stripping the leading RapidMove
after normalizing program coordinates to origin. This left programs
starting with a LinearMove, causing the post-processor to use that
endpoint as the pierce point — making the first contour edge zero-length
and losing the closing segment (e.g. the bottom line on curved parts).

Root cause: CadConverterForm.GetDrawings(), OnSplitClicked(), and
BomImportForm all called pgm.Codes.RemoveAt(0) after offsetting the
rapid to origin. The rapid at (0,0) is a harmless no-op that marks the
contour start point for downstream processing.

Also adds EnsureLeadingRapid() safety net in the Cincinnati post for
existing nest files that already have the rapid stripped.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-01 10:33:59 -04:00
parent fb067187b4
commit a8341e9e99
5 changed files with 101 additions and 4 deletions

View File

@@ -72,7 +72,27 @@ public static class FeatureUtils
public static List<(List<ICode> codes, bool isEtch)> SplitAndClassify(Part part)
{
part.Program.Mode = Mode.Absolute;
return ClassifyAndOrder(SplitByRapids(part.Program.Codes));
var codes = part.Program.Codes;
// If no leading rapid, the first contour segment would be lost because
// the feature writer pierces at the first motion endpoint. Insert a
// synthetic rapid at the contour's return point to preserve closure.
if (codes.Count > 0 && codes[0] is not RapidMove)
{
for (var i = codes.Count - 1; i >= 0; i--)
{
if (codes[i] is Motion lastMotion)
{
var withRapid = new List<ICode>(codes.Count + 1);
withRapid.Add(new RapidMove(lastMotion.EndPoint));
withRapid.AddRange(codes);
codes = withRapid;
break;
}
}
}
return ClassifyAndOrder(SplitByRapids(codes));
}
/// <summary>