2023-02-17 17:32:01 +00:00
|
|
|
import cadquery as cq
|
|
|
|
from cadquery import exporters
|
2023-02-16 17:57:32 +00:00
|
|
|
|
|
|
|
import battery_holder
|
2023-02-16 17:42:31 +00:00
|
|
|
import cpu_holder
|
2022-11-15 18:03:48 +00:00
|
|
|
|
|
|
|
# Base for the notebook. Basically a kbd base that extends back
|
|
|
|
# as much as possible
|
|
|
|
|
|
|
|
# Thickness of the outer material
|
|
|
|
shell_t = 3
|
|
|
|
|
2022-11-22 18:41:47 +00:00
|
|
|
# Size of the kbd board
|
2023-01-26 14:08:58 +00:00
|
|
|
kbd_height = 95.5
|
|
|
|
kbd_width = 305
|
2022-11-22 18:41:47 +00:00
|
|
|
kbd_angle = 5
|
|
|
|
|
|
|
|
# Size of the whole object
|
|
|
|
width = kbd_width + 2 * shell_t
|
2023-02-01 13:21:29 +00:00
|
|
|
height = 159
|
2023-02-16 18:08:21 +00:00
|
|
|
thickness = 27 + shell_t # 27 inside
|
2022-11-22 18:41:47 +00:00
|
|
|
|
2022-11-15 18:03:48 +00:00
|
|
|
# Insert Positions
|
|
|
|
ti_radius = 2.35
|
|
|
|
ti_depth = 6.25
|
|
|
|
|
2022-11-28 18:09:49 +00:00
|
|
|
# Positions are determined by measuring the keyboard
|
2023-01-27 14:23:04 +00:00
|
|
|
|
|
|
|
kbd_pillar_positions = [
|
|
|
|
(18.25, -16),
|
|
|
|
(142.5, -25.5),
|
|
|
|
(kbd_width - 20, -16),
|
|
|
|
(23.5, -79.5),
|
|
|
|
(145.5, -82.5),
|
|
|
|
(kbd_width - 19, -79.5),
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2023-02-01 13:21:29 +00:00
|
|
|
# 2-level mounting pillars for the kbd
|
|
|
|
# Width of these need to be tweaked for
|
|
|
|
# each specific keyboard
|
2022-11-28 18:09:49 +00:00
|
|
|
kbd_pillars = (
|
2022-11-15 18:03:48 +00:00
|
|
|
cq.Sketch()
|
2023-01-27 14:23:04 +00:00
|
|
|
.push(kbd_pillar_positions)
|
2023-01-26 18:11:16 +00:00
|
|
|
.circle(2.2, mode="a")
|
|
|
|
# Holes for self-tapping screws
|
2023-01-27 14:16:40 +00:00
|
|
|
.circle(1.1, mode="s")
|
2022-11-15 18:03:48 +00:00
|
|
|
)
|
|
|
|
|
2023-01-27 14:23:04 +00:00
|
|
|
kbd_lower_pillars = (
|
|
|
|
cq.Sketch()
|
|
|
|
.push(kbd_pillar_positions)
|
|
|
|
.circle(4, mode="a")
|
|
|
|
# Holes for self-tapping screws
|
|
|
|
.circle(1.1, mode="s")
|
|
|
|
)
|
|
|
|
|
2022-11-28 18:09:49 +00:00
|
|
|
# These are placed where convenient, and are used to join the top and bottom
|
|
|
|
# parts of the case.
|
|
|
|
# Measured from top-left corner OUTSIDE
|
|
|
|
mounting_pillar_positions = [
|
|
|
|
(6, -6),
|
2023-01-30 13:57:33 +00:00
|
|
|
(6, -40),
|
2022-11-28 18:09:49 +00:00
|
|
|
(120, -6),
|
|
|
|
(170, -6),
|
2022-12-02 13:04:23 +00:00
|
|
|
(width - 6, -6),
|
|
|
|
(width - 6, -40),
|
2022-11-28 18:09:49 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
mounting_pillars = (
|
|
|
|
cq.Sketch()
|
|
|
|
.push(mounting_pillar_positions)
|
|
|
|
.trapezoid(12, 12, 90, mode="a")
|
2022-11-29 12:27:15 +00:00
|
|
|
.circle(1.8, mode="s")
|
2022-11-28 18:09:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
screw_holes = cq.Sketch().push(mounting_pillar_positions).circle(3, mode="a")
|
|
|
|
|
2023-02-01 13:21:29 +00:00
|
|
|
# Hole for the USB hub's exposed port
|
2022-11-23 13:25:10 +00:00
|
|
|
usb_in = cq.Sketch().trapezoid(13, 5.5, 90, mode="a")
|
2022-11-28 18:09:49 +00:00
|
|
|
|
2023-02-22 14:25:50 +00:00
|
|
|
# Hole for the USB hub's exposed port
|
|
|
|
audio_in = cq.Sketch().trapezoid(17, 6, 90, mode="a")
|
|
|
|
|
|
|
|
|
2023-02-16 18:58:30 +00:00
|
|
|
# Holes for the battery power cable and button
|
|
|
|
power_in = cq.Sketch().trapezoid(10, 5.5, 90, mode="a")
|
|
|
|
power_button_cut = cq.Sketch().trapezoid(7, 7, 90, mode="a")
|
2022-11-28 18:09:49 +00:00
|
|
|
|
2023-02-16 17:42:31 +00:00
|
|
|
# CPU stand pins
|
|
|
|
lower_stands = (
|
|
|
|
cq.Sketch().push([(0, 0), (58, 0), (58, 23), (0, 23)]).circle(3, mode="a")
|
|
|
|
)
|
|
|
|
|
|
|
|
higher_stands = (
|
|
|
|
cq.Sketch().push([(0, 0), (58, 0), (58, 23), (0, 23)]).circle(2.65 / 2, mode="a")
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-11-15 18:24:45 +00:00
|
|
|
def model():
|
|
|
|
return (
|
|
|
|
cq.Workplane("XY")
|
|
|
|
.workplane(offset=thickness / 2)
|
|
|
|
.tag("mid_height")
|
|
|
|
# Hollow box
|
|
|
|
.box(width, height, thickness)
|
|
|
|
.edges("|Z")
|
|
|
|
.fillet(2)
|
|
|
|
.faces(">Z")
|
|
|
|
.shell(-shell_t)
|
2023-02-16 18:58:30 +00:00
|
|
|
# Power inlet
|
2023-02-22 14:25:50 +00:00
|
|
|
# The position is arbitrary, based on the components available
|
2023-02-16 18:58:30 +00:00
|
|
|
.faces(">Y")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
|
|
|
.center(width / 2 - 15 - 21, -8.5)
|
|
|
|
.placeSketch(power_in)
|
|
|
|
.cutBlind(-shell_t)
|
|
|
|
# Power button
|
2023-02-22 14:25:50 +00:00
|
|
|
# The position is arbitrary, based on the components available,
|
2023-02-16 18:58:30 +00:00
|
|
|
.faces(">Y")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
2023-02-17 13:08:05 +00:00
|
|
|
.center(width / 2 - 67 - 21, -1)
|
2023-02-16 18:58:30 +00:00
|
|
|
.placeSketch(power_button_cut)
|
|
|
|
.cutBlind(-shell_t)
|
2022-11-23 13:25:10 +00:00
|
|
|
# USB inlet
|
2023-02-22 14:25:50 +00:00
|
|
|
# The position is arbitrary, based on the components
|
|
|
|
# available, keyboard height, cable length, etc.
|
2022-11-23 13:25:10 +00:00
|
|
|
.faces(">X")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
2023-02-22 14:25:50 +00:00
|
|
|
.center(-height / 2 + shell_t + 45 + 13 / 2, -8)
|
|
|
|
.placeSketch(usb_in)
|
|
|
|
.cutBlind(-shell_t)
|
|
|
|
# Audio plugs
|
2023-02-16 17:57:51 +00:00
|
|
|
# The position is arbitrary, based on the components
|
2023-02-01 13:21:29 +00:00
|
|
|
# available, keyboard height, cable length, etc.
|
2023-02-22 14:25:50 +00:00
|
|
|
.faces("<Y")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
|
|
|
.center(width / 2 - shell_t - 34.5 - 17 / 2, -8)
|
|
|
|
.placeSketch(audio_in)
|
2022-11-23 13:25:10 +00:00
|
|
|
.cutBlind(-shell_t)
|
2022-11-15 18:24:45 +00:00
|
|
|
# Slanted mounting pillars on the kbd top
|
|
|
|
.faces(">Z")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
2022-11-22 18:41:47 +00:00
|
|
|
# Top-left kbd corner inside the box
|
|
|
|
.center(-width / 2 + shell_t, kbd_height - height / 2 + shell_t)
|
2022-11-15 18:24:45 +00:00
|
|
|
.transformed(rotate=cq.Vector(kbd_angle, 0, 0))
|
2023-02-01 13:21:29 +00:00
|
|
|
# These two offsets push the keyboard "down" into the case
|
|
|
|
# and need to be adjusted per-keyboard
|
2022-11-15 18:24:45 +00:00
|
|
|
.tag("sloped")
|
2023-02-01 13:21:29 +00:00
|
|
|
.workplane(offset=-2.5)
|
2022-11-28 18:09:49 +00:00
|
|
|
.placeSketch(kbd_pillars)
|
2022-11-15 18:24:45 +00:00
|
|
|
.extrude(-1000)
|
2023-01-27 14:23:04 +00:00
|
|
|
.workplaneFromTagged("sloped")
|
2023-02-01 13:21:29 +00:00
|
|
|
.workplane(offset=-5.5)
|
2023-01-27 14:23:04 +00:00
|
|
|
.placeSketch(kbd_lower_pillars)
|
|
|
|
.extrude(-1000)
|
2022-11-15 18:24:45 +00:00
|
|
|
# Remove the excess extrusion
|
|
|
|
.workplaneFromTagged("mid_height")
|
|
|
|
.transformed(offset=cq.Vector(0, 0, -thickness / 2))
|
|
|
|
.split(keepTop=True)
|
|
|
|
# Slope for the beyboard
|
|
|
|
.workplaneFromTagged("sloped")
|
|
|
|
.split(keepBottom=True)
|
2022-11-28 18:09:49 +00:00
|
|
|
# Pillars to join with top half
|
|
|
|
.workplaneFromTagged("mid_height")
|
|
|
|
.workplane(offset=-thickness / 2, centerOption="CenterOfBoundBox")
|
|
|
|
.center(-width / 2, height / 2)
|
|
|
|
.placeSketch(mounting_pillars)
|
|
|
|
.extrude(thickness)
|
|
|
|
# Holes to insert screws from the bottom
|
|
|
|
.workplaneFromTagged("mid_height")
|
|
|
|
.workplane(offset=-thickness / 2, centerOption="CenterOfBoundBox")
|
|
|
|
.center(-width / 2, height / 2)
|
|
|
|
.placeSketch(screw_holes)
|
|
|
|
# 13 is 20-7 (screw thread length - threaded insert depth)
|
|
|
|
.cutBlind(thickness - 13)
|
2023-02-16 17:42:31 +00:00
|
|
|
# CPU Stands (lower)
|
2023-02-16 17:57:51 +00:00
|
|
|
# The -65, -40 is the position of the CPU,
|
2023-02-16 17:42:31 +00:00
|
|
|
# and should be a parameter (TODO)
|
|
|
|
.workplaneFromTagged("mid_height")
|
|
|
|
.workplane(offset=-thickness / 2, centerOption="CenterOfBoundBox")
|
2023-02-16 17:57:51 +00:00
|
|
|
.center(width / 2 - 40, height / 2 - 65)
|
2023-02-16 17:42:31 +00:00
|
|
|
.placeSketch(cpu_holder.lower_stands)
|
|
|
|
.extrude(7)
|
|
|
|
# CPU Stands (higher)
|
|
|
|
.workplaneFromTagged("mid_height")
|
|
|
|
.workplane(offset=-thickness / 2, centerOption="CenterOfBoundBox")
|
2023-02-16 17:57:51 +00:00
|
|
|
.center(width / 2 - 40, height / 2 - 65)
|
2023-02-16 17:42:31 +00:00
|
|
|
.placeSketch(cpu_holder.higher_stands)
|
2023-02-17 13:08:05 +00:00
|
|
|
.extrude(13)
|
2023-02-16 17:57:32 +00:00
|
|
|
# Battery Stands (lower)
|
2023-02-16 17:57:51 +00:00
|
|
|
# The +18, -55 is the position of the battery system,
|
2023-02-16 17:57:32 +00:00
|
|
|
# and should be a parameter (TODO)
|
|
|
|
.workplaneFromTagged("mid_height")
|
|
|
|
.workplane(offset=-thickness / 2, centerOption="CenterOfBoundBox")
|
2023-02-17 13:08:05 +00:00
|
|
|
.center(-width / 2 + 21, height / 2 - 56)
|
2023-02-16 17:57:32 +00:00
|
|
|
.placeSketch(battery_holder.lower_stands)
|
|
|
|
.extrude(shell_t + 5)
|
|
|
|
# Battery Stands (higher)
|
|
|
|
.workplaneFromTagged("mid_height")
|
|
|
|
.workplane(offset=-thickness / 2, centerOption="CenterOfBoundBox")
|
2023-02-17 13:08:05 +00:00
|
|
|
.center(-width / 2 + 21, height / 2 - 56)
|
2023-02-16 17:57:32 +00:00
|
|
|
.placeSketch(battery_holder.higher_stands)
|
2023-02-17 13:08:05 +00:00
|
|
|
.extrude(shell_t + 11)
|
2022-11-15 18:24:45 +00:00
|
|
|
)
|
|
|
|
|
2022-11-15 19:01:20 +00:00
|
|
|
|
2022-11-28 18:09:49 +00:00
|
|
|
if __name__ == "__main__":
|
2022-11-15 18:24:45 +00:00
|
|
|
|
2022-11-28 18:09:49 +00:00
|
|
|
left_cutout = cq.Sketch().polygon(
|
2023-01-26 18:11:16 +00:00
|
|
|
[(0, 0), (width / 2, 0), (width / 2, -height), (0, -height), (0, 0)],
|
2022-11-28 18:09:49 +00:00
|
|
|
mode="a",
|
|
|
|
)
|
2022-11-15 18:24:45 +00:00
|
|
|
|
2022-11-28 18:09:49 +00:00
|
|
|
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)
|
|
|
|
)
|
2022-11-15 18:24:45 +00:00
|
|
|
|
2022-11-28 18:09:49 +00:00
|
|
|
exporters.export(right_side, "right_side.stl")
|
|
|
|
|
|
|
|
right_cutout = cq.Sketch().polygon(
|
|
|
|
[
|
2023-01-26 18:11:16 +00:00
|
|
|
(width / 2, 0),
|
2022-11-28 18:09:49 +00:00
|
|
|
(width, 0),
|
|
|
|
(width, -height),
|
2023-01-26 18:11:16 +00:00
|
|
|
(width / 2, -height),
|
|
|
|
(width / 2, 0),
|
2022-11-28 18:09:49 +00:00
|
|
|
],
|
|
|
|
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")
|
2022-11-15 18:03:48 +00:00
|
|
|
|
2022-11-28 18:09:49 +00:00
|
|
|
exporters.export(model(), "model.stl")
|