Refactor audio plug module
This commit is contained in:
parent
9904a412a3
commit
9bdabfdd98
@ -1,7 +1,10 @@
|
||||
# Hole to expose a USB audio card (YMMV)
|
||||
|
||||
# The hole is for a USB-A plug, y is measured in the hub
|
||||
# (from the bottom face to middle of the hole)
|
||||
import cadquery as cq
|
||||
|
||||
from utils import punch_hole2, extrude_shape2
|
||||
|
||||
# The hole is for a random USB sound card.
|
||||
# Consumers should set proper offsets for the hole
|
||||
|
||||
holes = [
|
||||
@ -9,8 +12,39 @@ holes = [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 4,
|
||||
"height": 6,
|
||||
"width": 17,
|
||||
"fillet": 2,
|
||||
"shape": cq.Sketch().trapezoid(17, 2, 90, mode="a").fillet(2),
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def add(
|
||||
*,
|
||||
model,
|
||||
width,
|
||||
height,
|
||||
thickness,
|
||||
offset_x,
|
||||
offset_y,
|
||||
bottom_face,
|
||||
back_face,
|
||||
shell_t
|
||||
):
|
||||
|
||||
# Holes
|
||||
if back_face:
|
||||
for hole in holes:
|
||||
model = punch_hole2(
|
||||
model=model,
|
||||
face=back_face,
|
||||
# FIXME: This is weird because it's the RIGHT side,
|
||||
# So it's height instead of w
|
||||
# need to work on making these coherent
|
||||
w=height,
|
||||
h=thickness,
|
||||
x_offset=offset_x - 17 / 2,
|
||||
y_offset=shell_t,
|
||||
hole=hole,
|
||||
depth=shell_t,
|
||||
)
|
||||
|
||||
return model
|
||||
|
Binary file not shown.
@ -180,17 +180,17 @@ def model():
|
||||
)
|
||||
|
||||
# Hole for audio in right side
|
||||
for hole in audio_plug.holes:
|
||||
model = punch_hole(
|
||||
model=model,
|
||||
face=">X",
|
||||
w=height,
|
||||
h=thickness,
|
||||
x_offset=height - shell_t - 34.5 - audio_plug.holes[0]["width"] / 2,
|
||||
y_offset=shell_t,
|
||||
hole=hole,
|
||||
depth=shell_t,
|
||||
)
|
||||
model = audio_plug.add(
|
||||
model=model,
|
||||
width=width,
|
||||
height=height,
|
||||
thickness=thickness,
|
||||
offset_x=111, # Offset from the front-left corner
|
||||
offset_y=0, # Offset from the bottom
|
||||
bottom_face=None,
|
||||
back_face=">X",
|
||||
shell_t=shell_t,
|
||||
)
|
||||
|
||||
model = cpu_holder.add(
|
||||
model=model,
|
||||
|
Binary file not shown.
@ -26,6 +26,16 @@ def punch_hole(*, model, face, w, h, x_offset, y_offset, hole, depth):
|
||||
)
|
||||
|
||||
|
||||
def extrude_shape2(*, model, face, w, h, x_offset, y_offset, hole, depth):
|
||||
return (
|
||||
model.faces(face)
|
||||
.workplane(centerOption="CenterOfBoundBox")
|
||||
.center(-w / 2 + x_offset + hole["x"], -h / 2 + y_offset + hole["y"])
|
||||
.placeSketch(hole["shape"])
|
||||
.extrude(-depth)
|
||||
)
|
||||
|
||||
|
||||
def punch_hole2(*, model, face, w, h, x_offset, y_offset, hole, depth):
|
||||
return (
|
||||
model.faces(face)
|
||||
@ -35,6 +45,7 @@ def punch_hole2(*, model, face, w, h, x_offset, y_offset, hole, depth):
|
||||
.cutBlind(-depth)
|
||||
)
|
||||
|
||||
|
||||
def hex_vents(*, size, width, height):
|
||||
vent_positions = []
|
||||
for x in range(1, width // size):
|
||||
@ -53,4 +64,4 @@ def hex_vents(*, size, width, height):
|
||||
}
|
||||
]
|
||||
|
||||
return vents
|
||||
return vents
|
||||
|
Loading…
Reference in New Issue
Block a user