Refactor zero_holder to match battery_holder, added vents

This commit is contained in:
Roberto Alsina 2023-03-15 10:15:40 -03:00
parent d9749bc38e
commit 4f1b09ab95
5 changed files with 119 additions and 18 deletions

View File

@ -1,5 +1,6 @@
import cadquery as cq
from utils import punch_hole2, extrude_shape, punch_hole
from utils import extrude_shape, punch_hole, punch_hole2
stand_positions = [(3.5, 3.5), (61.5, 3.5), (61.5, 52.5), (3.5, 52.5)]
stands = (
@ -70,7 +71,7 @@ elements = [
]
hex_size = width // 13
hex_size = 6
vent_positions = []
for x in range(1, width // hex_size):
for y in range(1, int(height // hex_size / 0.8)):
@ -80,13 +81,12 @@ for x in range(1, width // hex_size):
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,
"shape": cq.Sketch().push(vent_positions).regularPolygon((hex_size) / 2, 6),
}
]

Binary file not shown.

View File

@ -192,17 +192,16 @@ def model():
depth=shell_t,
)
# CPU holder stands
for element in cpu_holder.elements:
model = extrude_shape(
model = cpu_holder.add(
model=model,
face="<Z",
w=width,
h=height,
x_offset=cpu_offset_x + element["x"],
y_offset=shell_t + cpu_offset_y + element["y"],
shape=element["shape"],
height=-(element["height"] + shell_t),
width=width,
height=height,
thickness=thickness,
offset_x=cpu_offset_x,
offset_y=cpu_offset_y,
bottom_face="<Z",
back_face=None,
shell_t=shell_t,
)
# This adds all the holes and extrusions for the battery system

Binary file not shown.

View File

@ -1,10 +1,18 @@
import cadquery as cq
positions = [(0, 0), (0, 23), (58, 23), (58, 0)]
from utils import extrude_shape, punch_hole2
stands = cq.Sketch().push(positions).circle(3, mode="a").circle(2.65 / 2, mode="s")
width = 65
height = 30
pillar_height = 7
stand_positions = [(3.5, 3.5), (3.5, 26.5), (61.5, 26.5), (61.5, 3.5)]
stands = (
cq.Sketch().push(stand_positions).circle(3, mode="a").circle(2.65 / 2, mode="s")
)
elements = [
# CPU holder stands
{
@ -12,5 +20,99 @@ elements = [
"y": 0,
"shape": stands,
"height": pillar_height,
},
{
"x": 0,
"y": 0,
"shape": cq.Sketch().push(stand_positions).circle(5),
"height": 0,
},
# 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 = 6
vent_positions = []
for x in range(1, width // hex_size):
for y in range(1, int(height // hex_size / 0.8)):
vent_positions.append(
(
(x + (y % 2) / 2) * hex_size - hex_size * 0.2,
y * hex_size * 0.8 + hex_size * 0.2,
)
)
vents = [
{
"x": 0,
"y": 0,
"shape": cq.Sketch().push(vent_positions).regularPolygon((hex_size) / 2, 6),
}
]
holes = [] # TODO
def add(
*,
model,
width,
height,
thickness,
offset_x,
offset_y,
bottom_face,
back_face,
shell_t
):
# Vents
for vent in vents:
model = punch_hole2(
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,
)
# CPU holder extrusions
for element in elements:
model = extrude_shape(
model=model,
face=bottom_face,
w=width,
h=height,
x_offset=offset_x + element["x"],
y_offset=shell_t + offset_y + element["y"],
shape=element["shape"],
height=-(element["height"] + shell_t),
)
# Holes
for hole in holes:
model = punch_hole2(
model=model,
face=back_face,
w=width,
h=thickness,
x_offset=width - offset_x,
y_offset=shell_t,
hole=hole,
depth=shell_t,
)
return model