From ec1939bef4574771af5841fa127559a902483b08 Mon Sep 17 00:00:00 2001 From: Roman PASSLER Date: Sun, 1 Mar 2026 18:40:24 +0100 Subject: [PATCH] fix(copper-pour): add outline parameter and fallback to board outline Two issues fixed: 1. TypeScript schema was missing the outline parameter entirely, so MCP clients couldn't send pour boundary points. 2. Python code read "points" key but schema defined "outline" key. Now accepts "outline" (with "points" as fallback for backwards compatibility). When no outline is provided, automatically uses the board edge bounding box as the pour boundary. --- python/commands/routing.py | 27 +++++++++++++++++++++------ src/tools/routing.ts | 6 ++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/python/commands/routing.py b/python/commands/routing.py index 202f840..2aa366a 100644 --- a/python/commands/routing.py +++ b/python/commands/routing.py @@ -1058,16 +1058,31 @@ class RoutingCommands: net = params.get("net") clearance = params.get("clearance") min_width = params.get("minWidth", 0.2) - points = params.get("points", []) + points = params.get("outline", params.get("points", [])) priority = params.get("priority", 0) fill_type = params.get("fillType", "solid") # solid or hatched + # If no outline provided, use board outline if not points or len(points) < 3: - return { - "success": False, - "message": "Missing points", - "errorDetails": "At least 3 points are required for copper pour outline", - } + board_box = self.board.GetBoardEdgesBoundingBox() + if board_box.GetWidth() > 0 and board_box.GetHeight() > 0: + scale = 1000000 # nm to mm + x1 = board_box.GetX() / scale + y1 = board_box.GetY() / scale + x2 = (board_box.GetX() + board_box.GetWidth()) / scale + y2 = (board_box.GetY() + board_box.GetHeight()) / scale + points = [ + {"x": x1, "y": y1}, + {"x": x2, "y": y1}, + {"x": x2, "y": y2}, + {"x": x1, "y": y2}, + ] + else: + return { + "success": False, + "message": "Missing outline", + "errorDetails": "Provide an outline array or add a board outline first", + } # Get layer ID layer_id = self.board.GetLayerID(layer) diff --git a/src/tools/routing.ts b/src/tools/routing.ts index 691a903..f086608 100644 --- a/src/tools/routing.ts +++ b/src/tools/routing.ts @@ -105,6 +105,12 @@ export function registerRoutingTools( layer: z.string().describe("PCB layer"), net: z.string().describe("Net name"), clearance: z.number().optional().describe("Clearance in mm"), + outline: z + .array(z.object({ x: z.number(), y: z.number() })) + .optional() + .describe( + "Array of {x, y} points defining the pour boundary. If omitted, the board outline is used.", + ), }, async (args: any) => { const result = await callKicadScript("add_copper_pour", args);