refactor(io): migrate nest file extension from .zip to .opnest

Add FileExtension and FileFilter constants to NestFormat and update all
references across Console, MCP, Training, and WinForms projects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-18 07:26:04 -04:00
parent a487d33f52
commit d2eeb23107
7 changed files with 23 additions and 17 deletions
+12 -9
View File
@@ -152,7 +152,8 @@ static class NestConsole
static Nest LoadOrCreateNest(Options options) static Nest LoadOrCreateNest(Options options)
{ {
var nestFile = options.InputFiles.FirstOrDefault(f => var nestFile = options.InputFiles.FirstOrDefault(f =>
f.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)); f.EndsWith(NestFormat.FileExtension, StringComparison.OrdinalIgnoreCase)
|| f.EndsWith(".zip", StringComparison.OrdinalIgnoreCase));
var dxfFiles = options.InputFiles.Where(f => var dxfFiles = options.InputFiles.Where(f =>
f.EndsWith(".dxf", StringComparison.OrdinalIgnoreCase)).ToList(); f.EndsWith(".dxf", StringComparison.OrdinalIgnoreCase)).ToList();
@@ -190,7 +191,7 @@ static class NestConsole
// DXF-only mode: create a fresh nest. // DXF-only mode: create a fresh nest.
if (dxfFiles.Count == 0) if (dxfFiles.Count == 0)
{ {
Console.Error.WriteLine("Error: no nest (.zip) or DXF (.dxf) files specified"); Console.Error.WriteLine("Error: no nest (.opnest) or DXF (.dxf) files specified");
return null; return null;
} }
@@ -272,7 +273,9 @@ static class NestConsole
plate.PartSpacing = options.Spacing.Value; plate.PartSpacing = options.Spacing.Value;
// Only apply size override when it wasn't already used to create the plate. // Only apply size override when it wasn't already used to create the plate.
var hasDxfOnly = !options.InputFiles.Any(f => f.EndsWith(".zip", StringComparison.OrdinalIgnoreCase)); var hasDxfOnly = !options.InputFiles.Any(f =>
f.EndsWith(NestFormat.FileExtension, StringComparison.OrdinalIgnoreCase)
|| f.EndsWith(".zip", StringComparison.OrdinalIgnoreCase));
if (options.PlateSize.HasValue && !hasDxfOnly) if (options.PlateSize.HasValue && !hasDxfOnly)
plate.Size = options.PlateSize.Value; plate.Size = options.PlateSize.Value;
@@ -373,7 +376,7 @@ static class NestConsole
var firstInput = options.InputFiles[0]; var firstInput = options.InputFiles[0];
var outputFile = options.OutputFile ?? Path.Combine( var outputFile = options.OutputFile ?? Path.Combine(
Path.GetDirectoryName(firstInput), Path.GetDirectoryName(firstInput),
$"{Path.GetFileNameWithoutExtension(firstInput)}-result.zip"); $"{Path.GetFileNameWithoutExtension(firstInput)}-result{NestFormat.FileExtension}");
new NestWriter(nest).Write(outputFile); new NestWriter(nest).Write(outputFile);
Console.WriteLine($"Saved: {outputFile}"); Console.WriteLine($"Saved: {outputFile}");
@@ -384,12 +387,12 @@ static class NestConsole
Console.Error.WriteLine("Usage: OpenNest.Console <input-files...> [options]"); Console.Error.WriteLine("Usage: OpenNest.Console <input-files...> [options]");
Console.Error.WriteLine(); Console.Error.WriteLine();
Console.Error.WriteLine("Arguments:"); Console.Error.WriteLine("Arguments:");
Console.Error.WriteLine(" input-files One or more .zip nest files or .dxf drawing files"); Console.Error.WriteLine(" input-files One or more .opnest nest files or .dxf drawing files");
Console.Error.WriteLine(); Console.Error.WriteLine();
Console.Error.WriteLine("Modes:"); Console.Error.WriteLine("Modes:");
Console.Error.WriteLine(" <nest.zip> Load nest and fill (existing behavior)"); Console.Error.WriteLine(" <nest.opnest> Load nest and fill (existing behavior)");
Console.Error.WriteLine(" <part.dxf> --size WxL Import DXF, create plate, and fill"); Console.Error.WriteLine(" <part.dxf> --size WxL Import DXF, create plate, and fill");
Console.Error.WriteLine(" <nest.zip> <part.dxf> Load nest and add imported DXF drawings"); Console.Error.WriteLine(" <nest.opnest> <part.dxf> Load nest and add imported DXF drawings");
Console.Error.WriteLine(); Console.Error.WriteLine();
Console.Error.WriteLine("Options:"); Console.Error.WriteLine("Options:");
Console.Error.WriteLine(" --drawing <name> Drawing name to fill with (default: first drawing)"); Console.Error.WriteLine(" --drawing <name> Drawing name to fill with (default: first drawing)");
@@ -397,7 +400,7 @@ static class NestConsole
Console.Error.WriteLine(" --quantity <n> Max parts to place (default: 0 = unlimited)"); Console.Error.WriteLine(" --quantity <n> Max parts to place (default: 0 = unlimited)");
Console.Error.WriteLine(" --spacing <value> Override part spacing"); Console.Error.WriteLine(" --spacing <value> Override part spacing");
Console.Error.WriteLine(" --size <WxL> Override plate size (e.g. 60x120); required for DXF-only mode"); Console.Error.WriteLine(" --size <WxL> Override plate size (e.g. 60x120); required for DXF-only mode");
Console.Error.WriteLine(" --output <path> Output nest file path (default: <input>-result.zip)"); Console.Error.WriteLine(" --output <path> Output nest file path (default: <input>-result.opnest)");
Console.Error.WriteLine(" --template <path> Nest template for plate defaults (thickness, quadrant, material, spacing)"); Console.Error.WriteLine(" --template <path> Nest template for plate defaults (thickness, quadrant, material, spacing)");
Console.Error.WriteLine(" --autonest Use NFP-based mixed-part autonesting instead of linear fill"); Console.Error.WriteLine(" --autonest Use NFP-based mixed-part autonesting instead of linear fill");
Console.Error.WriteLine(" --keep-parts Don't clear existing parts before filling"); Console.Error.WriteLine(" --keep-parts Don't clear existing parts before filling");
+3
View File
@@ -5,6 +5,9 @@ namespace OpenNest.IO
{ {
public static class NestFormat public static class NestFormat
{ {
public const string FileExtension = ".opnest";
public const string FileFilter = "Nest Files (*.opnest)|*.opnest";
public static readonly JsonSerializerOptions JsonOptions = new() public static readonly JsonSerializerOptions JsonOptions = new()
{ {
PropertyNamingPolicy = JsonNamingPolicy.CamelCase, PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
+2 -2
View File
@@ -21,8 +21,8 @@ namespace OpenNest.Mcp.Tools
} }
[McpServerTool(Name = "load_nest")] [McpServerTool(Name = "load_nest")]
[Description("Load a .nest zip file into the session. Returns a summary of plates, parts, and drawings.")] [Description("Load an .opnest file into the session. Returns a summary of plates, parts, and drawings.")]
public string LoadNest([Description("Absolute path to the .nest file")] string path) public string LoadNest([Description("Absolute path to the .opnest file")] string path)
{ {
if (!File.Exists(path)) if (!File.Exists(path))
return $"Error: file not found: {path}"; return $"Error: file not found: {path}";
+2 -2
View File
@@ -17,10 +17,10 @@ namespace OpenNest.Mcp.Tools
[McpServerTool(Name = "test_engine")] [McpServerTool(Name = "test_engine")]
[Description("Build and run the nesting engine against a nest file. Returns fill results and a debug log file path for grepping. Use this to test engine changes without restarting the MCP server.")] [Description("Build and run the nesting engine against a nest file. Returns fill results and a debug log file path for grepping. Use this to test engine changes without restarting the MCP server.")]
public string TestEngine( public string TestEngine(
[Description("Path to the nest .zip file")] string nestFile = @"C:\Users\AJ\Desktop\4980 A24 PT02 60x120 45pcs v2.zip", [Description("Path to the nest .opnest file")] string nestFile = @"C:\Users\AJ\Desktop\4980 A24 PT02 60x120 45pcs v2.opnest",
[Description("Drawing name to fill with (default: first drawing)")] string drawingName = null, [Description("Drawing name to fill with (default: first drawing)")] string drawingName = null,
[Description("Plate index to fill (default: 0)")] int plateIndex = 0, [Description("Plate index to fill (default: 0)")] int plateIndex = 0,
[Description("Output nest file path (default: <input>-result.zip)")] string outputFile = null) [Description("Output nest file path (default: <input>-result.opnest)")] string outputFile = null)
{ {
if (!File.Exists(nestFile)) if (!File.Exists(nestFile))
return $"Error: nest file not found: {nestFile}"; return $"Error: nest file not found: {nestFile}";
+2 -2
View File
@@ -234,7 +234,7 @@ int RunDataCollection(string dir, string dbPath, string saveDir, double s, strin
Directory.CreateDirectory(partDir); Directory.CreateDirectory(partDir);
var nestName = $"{partNo}-{size.Length}x{size.Width}-{result.PartCount}pcs"; var nestName = $"{partNo}-{size.Length}x{size.Width}-{result.PartCount}pcs";
var fileName = nestName + ".zip"; var fileName = nestName + NestFormat.FileExtension;
savedFilePath = Path.Combine(partDir, fileName); savedFilePath = Path.Combine(partDir, fileName);
// Create nest from template or from scratch // Create nest from template or from scratch
@@ -299,7 +299,7 @@ void PrintUsage()
Console.Error.WriteLine("Options:"); Console.Error.WriteLine("Options:");
Console.Error.WriteLine(" --spacing <value> Part spacing (default: 0.5)"); Console.Error.WriteLine(" --spacing <value> Part spacing (default: 0.5)");
Console.Error.WriteLine(" --db <path> SQLite database path (default: OpenNestTraining.db)"); Console.Error.WriteLine(" --db <path> SQLite database path (default: OpenNestTraining.db)");
Console.Error.WriteLine(" --save-nests <dir> Directory to save individual .zip nests for each winner"); Console.Error.WriteLine(" --save-nests <dir> Directory to save individual .opnest nests for each winner");
Console.Error.WriteLine(" --template <path> Nest template (.nstdot) for plate defaults"); Console.Error.WriteLine(" --template <path> Nest template (.nstdot) for plate defaults");
Console.Error.WriteLine(" -h, --help Show this help"); Console.Error.WriteLine(" -h, --help Show this help");
} }
+1 -1
View File
@@ -288,7 +288,7 @@ namespace OpenNest.Forms
public void SaveAs() public void SaveAs()
{ {
var dlg = new SaveFileDialog(); var dlg = new SaveFileDialog();
dlg.Filter = "Nest Files|*.zip|Template File|*.nstdot"; dlg.Filter = $"{NestFormat.FileFilter}|Template File|*.nstdot";
dlg.FileName = Nest.Name; dlg.FileName = Nest.Name;
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+1 -1
View File
@@ -403,7 +403,7 @@ namespace OpenNest.Forms
private void Open_Click(object sender, EventArgs e) private void Open_Click(object sender, EventArgs e)
{ {
var dlg = new OpenFileDialog(); var dlg = new OpenFileDialog();
dlg.Filter = "Nest Files (*.zip) | *.zip"; dlg.Filter = NestFormat.FileFilter;
dlg.Multiselect = true; dlg.Multiselect = true;
if (dlg.ShowDialog() == DialogResult.OK) if (dlg.ShowDialog() == DialogResult.OK)