From 5125a5f2f37cccf1435433aabf2cc19c0f476b22 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Mon, 12 Oct 2026 19:00:50 -0400 Subject: [PATCH] fix(desktop): warn about clamp settings on BOM import BOM import read clamps.json without its status, so an unreadable or partly invalid file could give BOM-created nests no or partial clamps silently. New and BOM import now share one loader that warns once per session, and BOM import reads the settings when it creates the nests. The Clamps dialog no longer claims that all parts and nesting keep clear of clamps: it names Auto Nest and states that interactive fill and push, the overlap check and cutoffs do not avoid clamps yet. Review findings 7 and 9, Project Memory 4e5f566d. --- OpenNest/Forms/BomImportForm.cs | 6 +++--- OpenNest/Forms/ClampsForm.cs | 7 ++++--- OpenNest/Forms/MainForm.cs | 9 +++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/OpenNest/Forms/BomImportForm.cs b/OpenNest/Forms/BomImportForm.cs index 673104d..b172622 100644 --- a/OpenNest/Forms/BomImportForm.cs +++ b/OpenNest/Forms/BomImportForm.cs @@ -18,7 +18,6 @@ namespace OpenNest.Forms private readonly BindingList _parts; private Dictionary _groupSettings; private NestDefaults _defaults; - private ClampSettings _clamps; public Form MdiParentForm { get; set; } @@ -31,7 +30,6 @@ namespace OpenNest.Forms dgvParts.DataSource = _parts; _groupSettings = new Dictionary(); _defaults = MainForm.LoadSavedNestDefaults(out _); - _clamps = MainForm.LoadSavedClampSettings(out _); ApplyDefaults(); } @@ -412,6 +410,8 @@ namespace OpenNest.Forms var jobName = txtJobName.Text.Trim(); var nestsCreated = 0; var importErrors = new List(); + // Read when the nests are created, warning (once per session) like New does. + var clamps = MainForm.LoadClampSettings(this); foreach (var group in groups) { @@ -437,7 +437,7 @@ namespace OpenNest.Forms { // As New does: saved defaults, then the machine clamps in those units. _defaults.ApplyTo(nest); - _clamps.ApplyToNewNest(nest); + clamps.ApplyToNewNest(nest); } ); importErrors.AddRange(result.Errors); diff --git a/OpenNest/Forms/ClampsForm.cs b/OpenNest/Forms/ClampsForm.cs index 8143d76..ad3dbf8 100644 --- a/OpenNest/Forms/ClampsForm.cs +++ b/OpenNest/Forms/ClampsForm.cs @@ -63,9 +63,10 @@ public sealed class ClampsForm : Form MaximumSize = new Size(450, 0), Padding = new Padding(0, 0, 0, 8), Text = - "Fixed clamps along the plate edge through the origin. Parts and nesting keep " - + "clear of each clamp by the plate's bottom edge spacing. Clamps that do not " - + "reach a shorter plate are left off it.", + "Fixed clamps along the plate edge through the origin. Auto Nest keeps parts " + + "clear of each clamp by the plate's bottom edge spacing; clamps that do not " + + "reach a shorter plate are left off it. Interactive fill and push, the " + + "overlap check and cutoffs do not avoid clamps yet.", } ); diff --git a/OpenNest/Forms/MainForm.cs b/OpenNest/Forms/MainForm.cs index b44101f..5111cb4 100644 --- a/OpenNest/Forms/MainForm.cs +++ b/OpenNest/Forms/MainForm.cs @@ -198,16 +198,16 @@ namespace OpenNest.Forms var nest = new Nest(); LoadNestDefaults().ApplyTo(nest); // After the defaults so the rail is converted to the new nest's units. - LoadClampSettings().ApplyToNewNest(nest); + LoadClampSettings(this).ApplyToNewNest(nest); return nest; } /// - /// Loads the machine clamp settings (see ); an + /// Loads the machine clamp settings for creating new nests (New, BOM import); an /// unreadable or partly invalid file warns once per session, because the new nest's /// clamps may not match the machine. /// - private ClampSettings LoadClampSettings() + internal static ClampSettings LoadClampSettings(IWin32Window owner) { var settings = LoadSavedClampSettings(out var status); @@ -222,6 +222,7 @@ namespace OpenNest.Forms ? "could not be read, so new nests have no clamps" : "has invalid values that were ignored, so new nests may be missing clamps"; MessageBox.Show( + owner, $"The clamp settings file {problem}:\n{ClampSettings.DefaultPath}\n\nCheck the clamps in Nest > Clamps and use Save as Machine Defaults to rewrite the file.", "Clamps", MessageBoxButtons.OK, @@ -231,7 +232,7 @@ namespace OpenNest.Forms return settings; } - private bool clampSettingsWarned; + private static bool clampSettingsWarned; /// The single desktop entry point for the persisted machine clamp settings. internal static ClampSettings LoadSavedClampSettings(out ClampSettingsStatus status) =>