cadquery/notebook_nueva/battery_holder.py

115 lines
2.5 KiB
Python

import cadquery as cq
stand_positions = [(3.5, 3.5), (61.5, 3.5), (61.5, 52.5), (3.5, 52.5)]
stands = (
cq.Sketch().push(stand_positions).circle(3, mode="a").circle(2.65 / 2, mode="s")
)
pillar_height = 7
width = 85
height = 56
# This is a holder for DuPont cables so they connect to this
# things' pogo pins which are used to power the CPU
pin_positions = [(3.5, 0), (4 * 2.54 + 3.5, 0)]
pin_holder_width = 25
pin_holder_height = 15
pin_holder = (
cq.Sketch()
.polygon(
[
(0.5, 0),
(pin_holder_width, 0),
(pin_holder_width, pin_holder_height),
(0, pin_holder_height),
(0.5, 0),
],
mode="a",
)
.push(pin_positions)
.polygon(
[(0, 0), (2.6, 0), (2.6, pin_holder_height), (0, pin_holder_height), (0, 0)],
mode="s",
)
)
elements = [
# Battery holder stands
{
"x": 0,
"y": 0,
"shape": stands,
"height": pillar_height,
},
{
"x": 0,
"y": 0,
"shape": cq.Sketch().push(stand_positions).circle(5),
"height": 0,
},
# Pogo pin connector channels
{
"x": 3.5,
"y": 43.5,
"shape": pin_holder,
"height": 3,
},
# 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,
},
]
hex_size = width // 13
vent_positions = []
for x in range(1, width // hex_size):
for y in range(0, int(height // hex_size / 0.8) - 1):
vent_positions.append(
(
(x + (y % 2) / 2) * hex_size - hex_size * 0.2,
y * hex_size * 0.8 + hex_size * 0.2,
)
)
vents = cq.Sketch().push(vent_positions).regularPolygon((hex_size) / 2, 6)
vents = [
{
"x": 0,
"y": 0,
"shape": vents,
}
]
# 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
{
"x": -15,
"y": -1 + pillar_height,
"height": 6.5,
"width": 12,
"fillet": 1,
},
# Power button
{
"x": -67,
"y": 5.5 + pillar_height,
"height": 7,
"width": 7,
"fillet": 1,
},
]