From be1ba74b1fca17d588b3cfd342d5d9ebd94d5d11 Mon Sep 17 00:00:00 2001 From: StealthEyeLLC Date: Wed, 1 Jul 2026 16:09:20 +0000 Subject: [PATCH] Fix bottom silkscreen layer for tracks and arcs --- ...ert-easyeda-json-to-tscircuit-soup-json.ts | 4 +-- .../silkscreen-bottom-layer.test.ts | 33 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 tests/convert-to-soup-tests/silkscreen-bottom-layer.test.ts diff --git a/lib/convert-easyeda-json-to-tscircuit-soup-json.ts b/lib/convert-easyeda-json-to-tscircuit-soup-json.ts index 879f9971..37dde86f 100644 --- a/lib/convert-easyeda-json-to-tscircuit-soup-json.ts +++ b/lib/convert-easyeda-json-to-tscircuit-soup-json.ts @@ -110,7 +110,7 @@ const handleSilkscreenPath = ( type: "pcb_silkscreen_path", pcb_silkscreen_path_id: `pcb_silkscreen_path_${index + 1}`, pcb_component_id: "pcb_component_1", - layer: "top", // Assuming all silkscreen is on top layer + layer: getSideFromLayer(track.layer), route: track.points.map((point) => ({ x: milx10(point.x), y: milx10(point.y), @@ -144,7 +144,7 @@ const handleSilkscreenArc = (arc: z.infer, index: number) => { type: "pcb_silkscreen_path", pcb_silkscreen_path_id: `pcb_silkscreen_arc_${index + 1}`, pcb_component_id: "pcb_component_1", - layer: "top", // Assuming all silkscreen is on top layer + layer: getSideFromLayer(arc.layer), route: arcPath.map((p) => ({ x: milx10(p.x), y: milx10(p.y), diff --git a/tests/convert-to-soup-tests/silkscreen-bottom-layer.test.ts b/tests/convert-to-soup-tests/silkscreen-bottom-layer.test.ts new file mode 100644 index 00000000..bc1fae31 --- /dev/null +++ b/tests/convert-to-soup-tests/silkscreen-bottom-layer.test.ts @@ -0,0 +1,33 @@ +import { expect, test } from "bun:test" +import { convertEasyEdaJsonToCircuitJson, EasyEdaJsonSchema } from "lib/index" +import rawJson from "tests/assets/C265111.raweasy.json" + +test("bottom-layer (layer 4) silkscreen TRACK and ARC map to the bottom layer", () => { + const convert = (extraShapes: string[]) => { + const raw = structuredClone(rawJson) as any + for (const shape of extraShapes) { + raw.packageDetail.dataStr.shape.push(shape) + } + return convertEasyEdaJsonToCircuitJson(EasyEdaJsonSchema.parse(raw), { + shouldRecenter: false, + }) as Array<{ type: string; layer?: string }> + } + + const silkscreenPaths = (elements: T[]) => + elements.filter((element) => element.type === "pcb_silkscreen_path") + + const baseline = convert([]) + const withBottom = convert([ + "TRACK~1~4~~3990 3010 3995 3010~ggeBOTTRACK~0", + "ARC~1~4~~M 3990 3000 A 2 2 0 0 0 3994 3000~ggeBOTARC~0", + ]) + + const newPaths = silkscreenPaths(withBottom).slice( + silkscreenPaths(baseline).length, + ) + + expect(newPaths).toHaveLength(2) + for (const path of newPaths) { + expect(path.layer).toBe("bottom") + } +})