Skip to content

Commit 7e6041f

Browse files
authored
Add support for rotated pill shape hole (#457)
* Add support for rotated pill shape hole
1 parent f50879d commit 7e6041f

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { PCBViewer } from "../PCBViewer"
2+
3+
export const RotatedPillHole = () => {
4+
return (
5+
<div style={{ backgroundColor: "black" }}>
6+
<PCBViewer
7+
circuitJson={
8+
[
9+
{
10+
type: "pcb_board",
11+
pcb_board_id: "pcb_board_rotated_pill_0",
12+
center: { x: 0, y: 0 },
13+
thickness: 1.6,
14+
num_layers: 2,
15+
width: 20,
16+
height: 12,
17+
outline: undefined,
18+
material: "fr4",
19+
},
20+
{
21+
type: "pcb_hole",
22+
pcb_hole_id: "pcb_hole_rotated_pill_0",
23+
x: -4,
24+
y: 0,
25+
hole_shape: "pill",
26+
hole_width: 2.5,
27+
hole_height: 5,
28+
ccw_rotation: 45,
29+
},
30+
{
31+
type: "pcb_hole",
32+
pcb_hole_id: "pcb_hole_rotated_pill_1",
33+
x: 4,
34+
y: 0,
35+
hole_shape: "pill",
36+
hole_width: 2.5,
37+
hole_height: 5,
38+
ccw_rotation: 0,
39+
},
40+
] as any
41+
}
42+
/>
43+
</div>
44+
)
45+
}
46+
47+
export default RotatedPillHole

src/lib/convert-element-to-primitive.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type {
77
PcbNoteDimension,
88
PcbSmtPadRotatedPill,
99
PcbPanel,
10+
PcbHole,
11+
PcbHoleRotatedPill,
1012
} from "circuit-json"
1113
import { su } from "@tscircuit/circuit-json-util"
1214
import type { Primitive } from "./types"
@@ -282,6 +284,31 @@ export const convertElementToPrimitives = (
282284
_parent_source_component,
283285
},
284286
]
287+
} else if (
288+
element.hole_shape === "pill" ||
289+
element.hole_shape === "rotated_pill"
290+
) {
291+
const { x, y, hole_width, hole_height } = element
292+
293+
if (typeof hole_width !== "number" || typeof hole_height !== "number") {
294+
return []
295+
}
296+
297+
return [
298+
{
299+
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
300+
pcb_drawing_type: "pill",
301+
x,
302+
y,
303+
w: hole_width,
304+
h: hole_height,
305+
layer: "drill",
306+
_element: element,
307+
_parent_pcb_component,
308+
_parent_source_component,
309+
ccw_rotation: (element as PcbHoleRotatedPill).ccw_rotation,
310+
},
311+
]
285312
}
286313
// TODO square hole
287314
// TODO oval hole

0 commit comments

Comments
 (0)