diff --git a/lib/convert-easyeda-json-to-tscircuit-soup-json.ts b/lib/convert-easyeda-json-to-tscircuit-soup-json.ts index cd46a48..aabab4f 100644 --- a/lib/convert-easyeda-json-to-tscircuit-soup-json.ts +++ b/lib/convert-easyeda-json-to-tscircuit-soup-json.ts @@ -28,6 +28,7 @@ import { findBoundsAndCenter, transformPCBElements } from "@tscircuit/soup-util" import { compose, scale, translate } from "transformation-matrix" import { computeCenterOffset } from "./compute-center-offset" import { mm } from "@tscircuit/mm" +import { mil10ToMm } from "./utils/easyeda-unit-to-mm" const mil2mm = (mil: number | string) => { if (typeof mil === "number") return mm(`${mil}mil`) @@ -58,7 +59,7 @@ const handleSilkscreenPath = ( x: milx10(point.x), y: milx10(point.y), })), - stroke_width: track.width, + stroke_width: mil10ToMm(track.width), }) } @@ -82,7 +83,7 @@ const handleSilkscreenArc = (arc: z.infer, index: number) => { x: milx10(p.x), y: milx10(p.y), })), - stroke_width: mm(arc.width), + stroke_width: mil10ToMm(arc.width), } as Soup.PcbSilkscreenPathInput) } diff --git a/lib/schemas/single-letter-shape-schema.ts b/lib/schemas/single-letter-shape-schema.ts index c433cd7..c145e50 100644 --- a/lib/schemas/single-letter-shape-schema.ts +++ b/lib/schemas/single-letter-shape-schema.ts @@ -1,4 +1,6 @@ import { z } from "zod" +import { mm } from "@tscircuit/mm" +import { mil10ToMm } from "lib/utils/easyeda-unit-to-mm" /** I'll break down the elements in the `dataStr.head.shape` array and explain what they represent. This array contains instructions for drawing the schematic symbol of the component. @@ -272,7 +274,7 @@ const parsePath = (str: string): z.infer => { type: "PATH", pathData, fillColor, - strokeWidth: Number(strokeWidth), + strokeWidth: mil10ToMm(Number(strokeWidth)), strokeColor, id, } diff --git a/lib/utils/easyeda-unit-to-mm.ts b/lib/utils/easyeda-unit-to-mm.ts new file mode 100644 index 0000000..78fc5aa --- /dev/null +++ b/lib/utils/easyeda-unit-to-mm.ts @@ -0,0 +1,9 @@ +/** + * EasyEDA takes 10 mil as a basic factor, when a stroke width is 1, we can take it as 1*10mil = 10mil, is 2, we can take it as 2*10mil = 20mil, + * Ref: https://docs.easyeda.com/en/DocumentFormat/3-EasyEDA-PCB-File-Format/#unit + * + * 1 mil = 0.001 inch + * 1 inch = 25.4 mm + * 1 mil = 25.4/1000 = 0.0254 mm + */ +export const mil10ToMm = (value: number): number => value * 10 * 0.0254 diff --git a/tests/convert-to-soup-tests/__snapshots__/c5184526.snap.svg b/tests/convert-to-soup-tests/__snapshots__/c5184526.snap.svg index 9470b91..9eb799e 100644 --- a/tests/convert-to-soup-tests/__snapshots__/c5184526.snap.svg +++ b/tests/convert-to-soup-tests/__snapshots__/c5184526.snap.svg @@ -10,4 +10,4 @@ .pcb-silkscreen-top { stroke: #f2eda1; } .pcb-silkscreen-bottom { stroke: #f2eda1; } .pcb-silkscreen-text { fill: #f2eda1; } - \ No newline at end of file + \ No newline at end of file diff --git a/tests/convert-to-soup-tests/__snapshots__/c57759.snap.svg b/tests/convert-to-soup-tests/__snapshots__/c57759.snap.svg index 6538535..33a5abf 100644 --- a/tests/convert-to-soup-tests/__snapshots__/c57759.snap.svg +++ b/tests/convert-to-soup-tests/__snapshots__/c57759.snap.svg @@ -10,4 +10,4 @@ .pcb-silkscreen-top { stroke: #f2eda1; } .pcb-silkscreen-bottom { stroke: #f2eda1; } .pcb-silkscreen-text { fill: #f2eda1; } - \ No newline at end of file + \ No newline at end of file diff --git a/tests/convert-to-ts/__snapshots__/C2998002-to-ts.snap.svg b/tests/convert-to-ts/__snapshots__/C2998002-to-ts.snap.svg index 37cd462..1f49786 100644 --- a/tests/convert-to-ts/__snapshots__/C2998002-to-ts.snap.svg +++ b/tests/convert-to-ts/__snapshots__/C2998002-to-ts.snap.svg @@ -10,4 +10,4 @@ .pcb-silkscreen-top { stroke: #f2eda1; } .pcb-silkscreen-bottom { stroke: #f2eda1; } .pcb-silkscreen-text { fill: #f2eda1; } - \ No newline at end of file + \ No newline at end of file