2023-02-17 17:32:01 +00:00
|
|
|
import cadquery as cq
|
2023-03-15 13:15:40 +00:00
|
|
|
|
2023-03-27 19:57:55 +00:00
|
|
|
from utils import extrude_shape, punch_hole, hex_vents
|
2023-02-16 17:57:32 +00:00
|
|
|
|
2023-03-08 20:24:43 +00:00
|
|
|
stand_positions = [(3.5, 3.5), (61.5, 3.5), (61.5, 52.5), (3.5, 52.5)]
|
2023-02-24 13:46:19 +00:00
|
|
|
stands = (
|
|
|
|
cq.Sketch().push(stand_positions).circle(3, mode="a").circle(2.65 / 2, mode="s")
|
|
|
|
)
|
2023-02-22 18:02:10 +00:00
|
|
|
pillar_height = 7
|
2023-03-08 20:24:43 +00:00
|
|
|
width = 85
|
|
|
|
height = 56
|
2023-02-22 21:17:02 +00:00
|
|
|
|
2023-02-17 20:55:20 +00:00
|
|
|
# This is a holder for DuPont cables so they connect to this
|
|
|
|
# things' pogo pins which are used to power the CPU
|
2023-02-23 13:08:57 +00:00
|
|
|
pin_positions = [(3.5, 0), (4 * 2.54 + 3.5, 0)]
|
2023-02-22 17:17:29 +00:00
|
|
|
pin_holder_width = 25
|
|
|
|
pin_holder_height = 15
|
|
|
|
pin_holder = (
|
|
|
|
cq.Sketch()
|
|
|
|
.polygon(
|
|
|
|
[
|
2023-02-23 13:08:57 +00:00
|
|
|
(0.5, 0),
|
2023-02-22 17:17:29 +00:00
|
|
|
(pin_holder_width, 0),
|
|
|
|
(pin_holder_width, pin_holder_height),
|
|
|
|
(0, pin_holder_height),
|
2023-02-23 13:08:57 +00:00
|
|
|
(0.5, 0),
|
2023-02-22 17:17:29 +00:00
|
|
|
],
|
|
|
|
mode="a",
|
|
|
|
)
|
|
|
|
.push(pin_positions)
|
|
|
|
.polygon(
|
|
|
|
[(0, 0), (2.6, 0), (2.6, pin_holder_height), (0, pin_holder_height), (0, 0)],
|
|
|
|
mode="s",
|
2023-02-17 20:55:20 +00:00
|
|
|
)
|
2023-02-22 17:17:29 +00:00
|
|
|
)
|
2023-03-01 18:47:06 +00:00
|
|
|
|
|
|
|
elements = [
|
|
|
|
# Battery holder stands
|
|
|
|
{
|
|
|
|
"x": 0,
|
|
|
|
"y": 0,
|
|
|
|
"shape": stands,
|
|
|
|
"height": pillar_height,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"x": 0,
|
2023-03-08 20:24:43 +00:00
|
|
|
"y": 0,
|
|
|
|
"shape": cq.Sketch().push(stand_positions).circle(5),
|
|
|
|
"height": 0,
|
|
|
|
},
|
|
|
|
# Pogo pin connector channels
|
|
|
|
{
|
|
|
|
"x": 3.5,
|
|
|
|
"y": 43.5,
|
2023-03-01 18:47:06 +00:00
|
|
|
"shape": pin_holder,
|
|
|
|
"height": 3,
|
|
|
|
},
|
2023-03-08 20:24:43 +00:00
|
|
|
# Perimeter
|
|
|
|
{
|
|
|
|
"x": width / 2,
|
|
|
|
"y": height / 2,
|
|
|
|
"shape": (
|
|
|
|
cq.Sketch()
|
|
|
|
.trapezoid(width, height, 90, mode="a")
|
|
|
|
.trapezoid(width - 2, height - 2, 90, mode="s")
|
|
|
|
.vertices()
|
|
|
|
.fillet(3)
|
|
|
|
),
|
|
|
|
"height": 0.2,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2023-03-27 19:57:55 +00:00
|
|
|
vents = hex_vents(size=3, width=width, height=height)
|
2023-03-01 18:47:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Hole distances are relative to the rightmost pillar
|
|
|
|
# seen from the back of the case, that's why they are negative
|
|
|
|
# Heights are relative to base of pillars
|
|
|
|
# All distances are measured to the CENTER of the hole
|
|
|
|
holes = [
|
|
|
|
# Power inlet
|
|
|
|
{
|
2023-04-12 16:36:17 +00:00
|
|
|
"x": -18.5,
|
2023-03-01 18:47:06 +00:00
|
|
|
"y": -1 + pillar_height,
|
2023-03-14 17:42:01 +00:00
|
|
|
"shape": cq.Sketch().trapezoid(12, 6.5, 90, mode="a").vertices().fillet(1),
|
2023-03-01 18:47:06 +00:00
|
|
|
},
|
|
|
|
# Power button
|
|
|
|
{
|
2023-03-31 12:58:38 +00:00
|
|
|
"x": -70,
|
2023-03-01 18:47:06 +00:00
|
|
|
"y": 5.5 + pillar_height,
|
2023-03-14 17:42:01 +00:00
|
|
|
"shape": cq.Sketch().trapezoid(7, 7, 90, mode="a").vertices().fillet(1),
|
2023-03-01 18:47:06 +00:00
|
|
|
},
|
|
|
|
]
|
2023-03-14 17:42:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
def add(
|
|
|
|
*,
|
|
|
|
model,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
thickness,
|
|
|
|
offset_x,
|
|
|
|
offset_y,
|
|
|
|
bottom_face,
|
|
|
|
back_face,
|
|
|
|
shell_t
|
|
|
|
):
|
2023-03-15 13:46:36 +00:00
|
|
|
if bottom_face:
|
|
|
|
# Vents
|
|
|
|
for vent in vents:
|
2023-03-27 19:57:55 +00:00
|
|
|
model = punch_hole(
|
2023-03-15 13:46:36 +00:00
|
|
|
model=model,
|
|
|
|
face=bottom_face,
|
|
|
|
w=width,
|
|
|
|
h=height,
|
|
|
|
x_offset=offset_x + vent["x"],
|
|
|
|
y_offset=shell_t + offset_y + vent["y"],
|
|
|
|
hole=vent,
|
|
|
|
depth=shell_t,
|
|
|
|
)
|
2023-03-14 17:42:01 +00:00
|
|
|
|
2023-03-15 13:46:36 +00:00
|
|
|
# Battery holder stands and pogo pin holder
|
|
|
|
for element in elements:
|
|
|
|
model = extrude_shape(
|
|
|
|
model=model,
|
|
|
|
face=bottom_face,
|
|
|
|
w=width,
|
|
|
|
h=height,
|
2023-03-27 19:57:55 +00:00
|
|
|
x_offset=offset_x,
|
|
|
|
y_offset=shell_t + offset_y,
|
|
|
|
element=element,
|
2023-03-15 13:46:36 +00:00
|
|
|
height=-(element["height"] + shell_t),
|
|
|
|
)
|
2023-03-14 17:42:01 +00:00
|
|
|
|
2023-03-15 13:46:36 +00:00
|
|
|
if back_face:
|
|
|
|
# Holes
|
|
|
|
for hole in holes:
|
2023-03-27 19:57:55 +00:00
|
|
|
model = punch_hole(
|
2023-03-15 13:46:36 +00:00
|
|
|
model=model,
|
|
|
|
face=back_face,
|
|
|
|
w=width,
|
|
|
|
h=thickness,
|
|
|
|
x_offset=width - offset_x,
|
|
|
|
y_offset=shell_t,
|
|
|
|
hole=hole,
|
|
|
|
depth=shell_t,
|
|
|
|
)
|
2023-03-14 17:42:01 +00:00
|
|
|
|
|
|
|
return model
|