From aa8b6f3d9ea40d475886fd11a3e8342112c3bb1f Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Tue, 24 Mar 2026 13:18:57 -0400 Subject: [PATCH] fix: use plate size correctly when split axis is forced When user selects Vertical Only or Horizontal Only, use the smaller plate dimension as the constraint for that axis. Previously it filtered results from FitToPlate which produced no lines when the part already fit in the plate width but not height. Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest/Forms/SplitDrawingForm.cs | 40 ++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/OpenNest/Forms/SplitDrawingForm.cs b/OpenNest/Forms/SplitDrawingForm.cs index 489c146..44aefc5 100644 --- a/OpenNest/Forms/SplitDrawingForm.cs +++ b/OpenNest/Forms/SplitDrawingForm.cs @@ -70,16 +70,40 @@ public partial class SplitDrawingForm : Form var plateH = (double)nudPlateHeight.Value; var spacing = (double)nudEdgeSpacing.Value; var overhang = GetCurrentParameters().FeatureOverhang; - var lines = AutoSplitCalculator.FitToPlate(_drawingBounds, plateW, plateH, spacing, overhang); - - // Filter by user-selected axis var axisIndex = cboSplitAxis.SelectedIndex; - if (axisIndex == 1) // Vertical Only - lines = lines.Where(l => l.Axis == CutOffAxis.Vertical).ToList(); - else if (axisIndex == 2) // Horizontal Only - lines = lines.Where(l => l.Axis == CutOffAxis.Horizontal).ToList(); - _splitLines.AddRange(lines); + if (axisIndex == 1) // Vertical Only — split the part width using the plate size + { + var usable = System.Math.Min(plateW, plateH) - 2 * spacing - overhang; + if (usable > 0) + { + var splits = (int)System.Math.Ceiling(_drawingBounds.Width / usable) - 1; + if (splits > 0) + { + var step = _drawingBounds.Width / (splits + 1); + for (var i = 1; i <= splits; i++) + _splitLines.Add(new SplitLine(_drawingBounds.X + step * i, CutOffAxis.Vertical)); + } + } + } + else if (axisIndex == 2) // Horizontal Only — split the part height using the plate size + { + var usable = System.Math.Min(plateW, plateH) - 2 * spacing - overhang; + if (usable > 0) + { + var splits = (int)System.Math.Ceiling(_drawingBounds.Length / usable) - 1; + if (splits > 0) + { + var step = _drawingBounds.Length / (splits + 1); + for (var i = 1; i <= splits; i++) + _splitLines.Add(new SplitLine(_drawingBounds.Y + step * i, CutOffAxis.Horizontal)); + } + } + } + else // Auto — both axes + { + _splitLines.AddRange(AutoSplitCalculator.FitToPlate(_drawingBounds, plateW, plateH, spacing, overhang)); + } } else if (radByCount.Checked) {