Refactored usb hub module
This commit is contained in:
parent
9bdabfdd98
commit
cdf2e33f64
@ -12,7 +12,7 @@ holes = [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 4,
|
||||
"shape": cq.Sketch().trapezoid(17, 2, 90, mode="a").fillet(2),
|
||||
"shape": cq.Sketch().trapezoid(17, 5, 90, mode="a").fillet(2),
|
||||
},
|
||||
]
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
@ -153,31 +153,17 @@ def model():
|
||||
# Now the basic box shape is in place, start adding things
|
||||
# and cutting holes.
|
||||
|
||||
# Hole for USB hub in the back
|
||||
for hole in usb_hub.holes:
|
||||
model = punch_hole(
|
||||
model=model,
|
||||
face=">Y",
|
||||
w=width,
|
||||
h=thickness,
|
||||
x_offset=usb_offset + shell_t + usb_hub.holes[0]["width"] / 2,
|
||||
y_offset=shell_t,
|
||||
hole=hole,
|
||||
depth=shell_t,
|
||||
)
|
||||
|
||||
# USB hub holder
|
||||
for element in usb_hub.elements:
|
||||
model = extrude_shape(
|
||||
model=model,
|
||||
face="<Z",
|
||||
w=width,
|
||||
h=height,
|
||||
x_offset=width - usb_offset - shell_t - +usb_hub.holes[0]["width"] / 2,
|
||||
y_offset=shell_t + element["y"],
|
||||
shape=element["shape"],
|
||||
height=-(element["height"] + shell_t),
|
||||
)
|
||||
model = usb_hub.add(
|
||||
model=model,
|
||||
width=width,
|
||||
height=height,
|
||||
thickness=thickness,
|
||||
bottom_face="<Z",
|
||||
back_face=">Y",
|
||||
offset_x=width - usb_offset,
|
||||
offset_y=0,
|
||||
shell_t=shell_t,
|
||||
)
|
||||
|
||||
# Hole for audio in right side
|
||||
model = audio_plug.add(
|
||||
@ -222,43 +208,43 @@ def model():
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
left_cutout = cq.Sketch().polygon(
|
||||
[(0, 0), (width / 2, 0), (width / 2, -height), (0, -height), (0, 0)],
|
||||
mode="a",
|
||||
)
|
||||
# left_cutout = cq.Sketch().polygon(
|
||||
# [(0, 0), (width / 2, 0), (width / 2, -height), (0, -height), (0, 0)],
|
||||
# mode="a",
|
||||
# )
|
||||
|
||||
right_side = (
|
||||
model()
|
||||
.faces("<Z")
|
||||
.workplaneFromTagged("mid_height")
|
||||
.transformed(offset=cq.Vector(0, 0, -thickness / 2))
|
||||
.center(-width / 2, height / 2)
|
||||
.placeSketch(left_cutout)
|
||||
.cutBlind(100)
|
||||
)
|
||||
# right_side = (
|
||||
# model()
|
||||
# .faces("<Z")
|
||||
# .workplaneFromTagged("mid_height")
|
||||
# .transformed(offset=cq.Vector(0, 0, -thickness / 2))
|
||||
# .center(-width / 2, height / 2)
|
||||
# .placeSketch(left_cutout)
|
||||
# .cutBlind(100)
|
||||
# )
|
||||
|
||||
exporters.export(right_side, "right_side.stl")
|
||||
# exporters.export(right_side, "right_side.stl")
|
||||
|
||||
right_cutout = cq.Sketch().polygon(
|
||||
[
|
||||
(width / 2, 0),
|
||||
(width, 0),
|
||||
(width, -height),
|
||||
(width / 2, -height),
|
||||
(width / 2, 0),
|
||||
],
|
||||
mode="a",
|
||||
)
|
||||
# right_cutout = cq.Sketch().polygon(
|
||||
# [
|
||||
# (width / 2, 0),
|
||||
# (width, 0),
|
||||
# (width, -height),
|
||||
# (width / 2, -height),
|
||||
# (width / 2, 0),
|
||||
# ],
|
||||
# mode="a",
|
||||
# )
|
||||
|
||||
left_side = (
|
||||
model()
|
||||
.faces("<Z")
|
||||
.workplaneFromTagged("mid_height")
|
||||
.transformed(offset=cq.Vector(0, 0, -thickness / 2))
|
||||
.center(-width / 2, height / 2)
|
||||
.placeSketch(right_cutout)
|
||||
.cutBlind(100)
|
||||
)
|
||||
exporters.export(left_side, "left_side.stl")
|
||||
# left_side = (
|
||||
# model()
|
||||
# .faces("<Z")
|
||||
# .workplaneFromTagged("mid_height")
|
||||
# .transformed(offset=cq.Vector(0, 0, -thickness / 2))
|
||||
# .center(-width / 2, height / 2)
|
||||
# .placeSketch(right_cutout)
|
||||
# .cutBlind(100)
|
||||
# )
|
||||
# exporters.export(left_side, "left_side.stl")
|
||||
|
||||
exporters.export(model(), "model.stl")
|
||||
|
Binary file not shown.
@ -1,5 +1,7 @@
|
||||
import cadquery as cq
|
||||
|
||||
from utils import punch_hole2, extrude_shape, extrude_shape2
|
||||
|
||||
# Measurements for my USB hub, YMMV
|
||||
|
||||
# The hole is for a USB-A plug, y is measured in the hub
|
||||
@ -11,9 +13,7 @@ holes = [
|
||||
{
|
||||
"x": 0,
|
||||
"y": 4,
|
||||
"height": 5.5,
|
||||
"width": 13,
|
||||
"fillet": 2,
|
||||
"shape": cq.Sketch().trapezoid(13, 5, 90, mode="a").vertices().fillet(2),
|
||||
},
|
||||
]
|
||||
|
||||
@ -31,3 +31,47 @@ elements = [
|
||||
"height": 8,
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
def add(
|
||||
*,
|
||||
model,
|
||||
width,
|
||||
height,
|
||||
thickness,
|
||||
offset_x,
|
||||
offset_y,
|
||||
bottom_face,
|
||||
back_face,
|
||||
shell_t
|
||||
):
|
||||
|
||||
# USB Hub extrusions
|
||||
if bottom_face:
|
||||
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
|
||||
if back_face:
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user