Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convertEasyEdaJsonToCircuitJson: convert oval pads with hole radius to pill-shaped plated holes #83

Merged
merged 6 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions lib/convert-easyeda-json-to-tscircuit-soup-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {
PCBSMTPad,
PcbSilkscreenPath,
PCBPlatedHole,
PCBPlatedHoleInput,
PcbPlatedHoleInput,
PcbComponentInput,
} from "circuit-json"
import {
Expand Down Expand Up @@ -149,21 +149,40 @@ export const convertEasyEdaJsonToCircuitJson = (

if (pad.holeRadius !== undefined && mil2mm(pad.holeRadius) !== 0) {
// Add pcb_plated_hole
soupElements.push(
pcb_plated_hole.parse({
type: "pcb_plated_hole",
pcb_plated_hole_id: `pcb_plated_hole_${index + 1}`,
const commonPlatedHoleProps = {
type: "pcb_plated_hole",
pcb_plated_hole_id: `pcb_plated_hole_${index + 1}`,
x: mil2mm(pad.center.x),
y: mil2mm(pad.center.y),
layers: ["top"],
port_hints: [portNumber],
pcb_component_id: "pcb_component_1",
pcb_port_id: `pcb_port_${index + 1}`,
}
let additionalPlatedHoleProps

if (pad.shape === "OVAL") {
additionalPlatedHoleProps = {
shape: "pill",
outer_width: mil2mm(pad.width),
outer_height: mil2mm(pad.height),
hole_width: mil2mm(pad.holeRadius) * 2,
hole_height: mil2mm(pad.holeRadius) * 2,
}
} else {
additionalPlatedHoleProps = {
shape: "circle",
x: mil2mm(pad.center.x),
y: mil2mm(pad.center.y),
hole_diameter: mil2mm(pad.holeRadius) * 2,
outer_diameter: mil2mm(pad.width),
radius: mil2mm(pad.holeRadius),
port_hints: [portNumber],
pcb_component_id: "pcb_component_1",
pcb_port_id: `pcb_port_${index + 1}`,
layers: ["top"],
} as PCBPlatedHoleInput),
}
}

soupElements.push(
pcb_plated_hole.parse({
...commonPlatedHoleProps,
...additionalPlatedHoleProps,
}),
)
} else {
// Add pcb_smtpad
Expand Down
Loading
Loading