Skip to content

Commit 27c8a7f

Browse files
author
techmannih
committed
Add support for rotated pill shape hole
1 parent f50879d commit 27c8a7f

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-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+
hole_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+
hole_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: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,35 @@ export const convertElementToPrimitives = (
282282
_parent_source_component,
283283
},
284284
]
285+
} else if (
286+
element.hole_shape === "pill" ||
287+
element.hole_shape === "rotated_pill"
288+
) {
289+
const { x, y, hole_width, hole_height } = element as any
290+
const ccw_rotation =
291+
(element as any).hole_ccw_rotation ??
292+
(element as any).ccw_rotation ??
293+
0
294+
295+
if (typeof hole_width !== "number" || typeof hole_height !== "number") {
296+
return []
297+
}
298+
299+
return [
300+
{
301+
_pcb_drawing_object_id: `pill_${globalPcbDrawingObjectCount++}`,
302+
pcb_drawing_type: "pill",
303+
x,
304+
y,
305+
w: hole_width,
306+
h: hole_height,
307+
layer: "drill",
308+
_element: element,
309+
_parent_pcb_component,
310+
_parent_source_component,
311+
ccw_rotation,
312+
},
313+
]
285314
}
286315
// TODO square hole
287316
// TODO oval hole

0 commit comments

Comments
 (0)