From 9d57d3875a2738890758cbc7c9b7167335a135cd Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Wed, 15 Apr 2026 06:17:26 -0400 Subject: [PATCH] fix(cnc): offset SubProgramCall positions in Program.Offset Program.Offset only adjusted Motion codes, so subprogram calls kept their original offsets after a part was translated. Apply the offset to SubProgramCall.Offset too so hole subprograms follow the part. Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest.Core/CNC/Program.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/OpenNest.Core/CNC/Program.cs b/OpenNest.Core/CNC/Program.cs index 1329314..c4a7103 100644 --- a/OpenNest.Core/CNC/Program.cs +++ b/OpenNest.Core/CNC/Program.cs @@ -128,6 +128,12 @@ namespace OpenNest.CNC { var code = Codes[i]; + if (code is SubProgramCall subpgm) + { + subpgm.Offset = new Geometry.Vector( + subpgm.Offset.X + x, subpgm.Offset.Y + y); + } + if (code is Motion == false) continue; @@ -150,6 +156,12 @@ namespace OpenNest.CNC { var code = Codes[i]; + if (code is SubProgramCall subpgm) + { + subpgm.Offset = new Geometry.Vector( + subpgm.Offset.X + voffset.X, subpgm.Offset.Y + voffset.Y); + } + if (code is Motion == false) continue;