Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions lib/components/primitive-components/PlatedHole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { PrimitiveComponent } from "../base-components/PrimitiveComponent"
import { platedHoleProps } from "@tscircuit/props"
import type { Port } from "./Port"
import type {
PCBPlatedHoleInput,
PcbPlatedHoleOval,
PcbHoleCircularWithRectPad,
PcbHolePillWithRectPad,
Expand Down Expand Up @@ -109,17 +108,18 @@ export class PlatedHole extends PrimitiveComponent<typeof platedHoleProps> {
const pcb_plated_hole = db.pcb_plated_hole.insert({
pcb_component_id,
pcb_port_id: this.matchedPort?.pcb_port_id!,
// @ts-ignore - some issue with circuit-json union type
outer_diameter: props.outerDiameter,
hole_diameter: props.holeDiameter,
shape: "circle" as const,
outer_width: props.outerDiameter,
outer_height: props.outerDiameter,
hole_width: props.holeDiameter,
hole_height: props.holeDiameter,
shape: "oval" as const,
port_hints: this.getNameAndAliases(),
x: position.x,
y: position.y,
layers: ["top", "bottom"],
subcircuit_id: subcircuit?.subcircuit_id ?? undefined,
pcb_group_id: this.getGroup()?.pcb_group_id ?? undefined,
})
} as PcbPlatedHoleOval)

this.pcb_plated_hole_id = pcb_plated_hole.pcb_plated_hole_id
db.pcb_solder_paste.insert({
Expand Down
11 changes: 8 additions & 3 deletions lib/utils/createComponentsFromCircuitJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,19 @@ export const createComponentsFromCircuitJson = (
}),
)
} else if (elm.type === "pcb_plated_hole") {
if (elm.shape === "circle") {
if (
(elm.shape === "oval" &&
elm.outer_width === elm.outer_height &&
elm.hole_width === elm.hole_height) ||
elm.shape === "circle"
) {
components.push(
new PlatedHole({
pcbX: elm.x,
pcbY: elm.y,
shape: "circle",
holeDiameter: elm.hole_diameter,
outerDiameter: elm.outer_diameter,
holeDiameter: elm.hole_diameter ?? elm.hole_width,
outerDiameter: elm.outer_diameter ?? elm.outer_width,
portHints: elm.port_hints,
}),
)
Expand Down
9 changes: 6 additions & 3 deletions lib/utils/obstacles/getObstaclesFromCircuitJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ export const getObstaclesFromCircuitJson = (
})
}
} else if (element.type === "pcb_plated_hole") {
if (element.shape === "circle") {
if (
element.shape === "circle" ||
(element.shape === "oval" && element.outer_width === element.outer_height)
) {
obstacles.push({
// @ts-ignore
type: "oval",
Expand All @@ -195,8 +198,8 @@ export const getObstaclesFromCircuitJson = (
x: element.x,
y: element.y,
},
width: element.outer_diameter,
height: element.outer_diameter,
width: element.outer_diameter ?? element.outer_width,
height: element.outer_diameter ?? element.outer_height,
connectedTo: withNetId([element.pcb_plated_hole_id]),
})
} else if (element.shape === "circular_hole_with_rect_pad") {
Expand Down