feat: add import_svg_logo tool — converts SVG to PCB silkscreen polygons
This commit is contained in:
@@ -346,4 +346,41 @@ export function registerBoardTools(server: McpServer, callKicadScript: CommandFu
|
||||
);
|
||||
|
||||
logger.info('Board management tools registered');
|
||||
|
||||
// Import SVG logo onto PCB layer (silkscreen)
|
||||
server.tool(
|
||||
"import_svg_logo",
|
||||
"Imports an SVG file as filled graphic polygons onto a KiCAD PCB layer (default F.SilkS / front silkscreen). Curves are linearised automatically. Ideal for placing a company or project logo on the board.",
|
||||
{
|
||||
pcbPath: z.string().describe("Path to the .kicad_pcb file"),
|
||||
svgPath: z.string().describe("Path to the SVG logo file"),
|
||||
x: z.number().describe("X position of the logo top-left corner in mm"),
|
||||
y: z.number().describe("Y position of the logo top-left corner in mm"),
|
||||
width: z.number().describe("Target width of the logo in mm (height is scaled to preserve aspect ratio)"),
|
||||
layer: z.string().optional().describe("PCB layer name, e.g. F.SilkS or B.SilkS (default: F.SilkS)"),
|
||||
strokeWidth: z.number().optional().describe("Outline stroke width in mm (0 = no outline, default 0)"),
|
||||
filled: z.boolean().optional().describe("Fill polygons with solid colour (default true)"),
|
||||
},
|
||||
async (args: { pcbPath: string; svgPath: string; x: number; y: number; width: number; layer?: string; strokeWidth?: number; filled?: boolean }) => {
|
||||
const result = await callKicadScript("import_svg_logo", args);
|
||||
if (result.success) {
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
text: [
|
||||
result.message,
|
||||
`Polygons: ${result.polygon_count}`,
|
||||
`Size: ${result.logo_width_mm?.toFixed(2)} × ${result.logo_height_mm?.toFixed(2)} mm`,
|
||||
`Layer: ${result.layer}`,
|
||||
].join("\n"),
|
||||
}],
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
content: [{ type: "text", text: `SVG import failed: ${result.message || "Unknown error"}` }],
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user