fix: assign part colors to drawings created by BOM importer and MCP

Drawings created by BomImportForm and MCP InputTools were missing color
assignments, causing them to render with default empty color instead of
the standard part color palette. Moved PartColors and GetNextColor() to
Drawing in Core so all consumers share one definition.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-05 23:49:48 -04:00
parent ed082a6799
commit a65598615e
6 changed files with 33 additions and 38 deletions

View File

@@ -112,6 +112,7 @@ namespace OpenNest.Mcp.Tools
var drawingName = name ?? Path.GetFileNameWithoutExtension(path);
var drawing = new Drawing(drawingName, pgm);
drawing.Color = Drawing.GetNextColor();
_session.Drawings.Add(drawing);
var bbox = pgm.BoundingBox();
@@ -155,6 +156,7 @@ namespace OpenNest.Mcp.Tools
if (pgm == null)
return "Error: failed to parse G-code";
var gcodeDrawing = new Drawing(name, pgm);
gcodeDrawing.Color = Drawing.GetNextColor();
_session.Drawings.Add(gcodeDrawing);
var gcodeBbox = pgm.BoundingBox();
return $"Created drawing '{name}': bbox={gcodeBbox.Width:F2} x {gcodeBbox.Length:F2}";
@@ -164,6 +166,7 @@ namespace OpenNest.Mcp.Tools
}
var drawing = shapeDef.GetDrawing();
drawing.Color = Drawing.GetNextColor();
_session.Drawings.Add(drawing);
var bbox = drawing.Program.BoundingBox();