-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcad.py
43 lines (32 loc) · 1.01 KB
/
cad.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import numpy as np
import solid as sp
import layout, utils
def place_switch(position, orientation):
return sp.translate(position)(
sp.rotate((0, 0, orientation))(sp.square([14, 14], center=True))
)
def switch_cutouts(positions, orientations):
for a in range(0, layout.num_switches):
col, row = divmod(a, layout.matrix_rows)
yield place_switch(positions[col, row], orientations[col, row])
def mcu_header_cutouts(mcu_position):
return sp.translate(mcu_position)(
[
sp.translate([x, -1.2])(sp.square([4.5, 33], center=True))
for x in [-7.6, 7.6]
],
)
def case_outline(outline):
return sp.minkowski()(
sp.polygon(points=outline),
sp.circle(r=15.),
)
def case_panel(outline, mounting_holes):
return sp.difference()(
case_outline(outline),
[
sp.translate(p)(
sp.circle(d=layout.mounting_hole_diameter, segments=32)
) for p in mounting_holes
],
)