2022-11-24 20:45:59 +00:00
|
|
|
import cadquery2 as cq
|
|
|
|
from cadquery2 import exporters
|
|
|
|
|
2022-11-25 20:11:31 +00:00
|
|
|
# Some dimensions copied from modelo.py,
|
2022-11-24 20:45:59 +00:00
|
|
|
# TODO refactor into a separate file
|
|
|
|
|
|
|
|
# Thickness of the outer material
|
|
|
|
shell_t = 3
|
|
|
|
|
|
|
|
# Size of the kbd board
|
|
|
|
kbd_height = 98
|
|
|
|
kbd_width = 286
|
|
|
|
kbd_angle = 5
|
|
|
|
|
|
|
|
# Size of the whole object
|
|
|
|
width = kbd_width + 2 * shell_t
|
|
|
|
height = 69
|
|
|
|
thickness = 10
|
|
|
|
|
|
|
|
# Visible screen size
|
2022-11-25 15:28:39 +00:00
|
|
|
vis_w = 220
|
2022-11-24 20:45:59 +00:00
|
|
|
vis_h = 58
|
|
|
|
viewport_cutout = cq.Sketch().trapezoid(vis_w, vis_h, 90, mode="a")
|
|
|
|
|
|
|
|
# Whole screen size
|
|
|
|
scr_w = 231
|
|
|
|
scr_h = 65
|
|
|
|
scr_thickness = 5.5
|
|
|
|
screen_cutout = cq.Sketch().trapezoid(scr_w, scr_h, 90, mode="a")
|
|
|
|
|
2022-11-25 20:11:31 +00:00
|
|
|
# Circuit board and cable hole.
|
|
|
|
# This is in the back of the screen, and is a bit shorter in height than the
|
|
|
|
# screen. It's wider so it removes enough material to make the shape simpler.
|
2022-11-25 17:46:30 +00:00
|
|
|
board_cutout = cq.Sketch().trapezoid(
|
|
|
|
scr_w + 5,
|
|
|
|
scr_h - 10,
|
|
|
|
90,
|
2022-11-25 15:28:39 +00:00
|
|
|
mode="a",
|
|
|
|
)
|
|
|
|
|
2022-11-25 20:11:31 +00:00
|
|
|
|
2022-11-25 15:28:39 +00:00
|
|
|
def model():
|
|
|
|
return (
|
|
|
|
cq.Workplane("XY")
|
2022-11-25 21:15:42 +00:00
|
|
|
.workplane().tag("mid_height")
|
|
|
|
.box(width, 59, 62)
|
2022-11-25 15:28:39 +00:00
|
|
|
.faces(">Z")
|
|
|
|
.transformed(rotate=(45, 0, 0))
|
2022-11-25 21:15:42 +00:00
|
|
|
# Move the screen "lower" so it doesn't interfere
|
|
|
|
# so much with the back
|
|
|
|
.center(0, -2)
|
2022-11-25 15:28:39 +00:00
|
|
|
.tag("slanted")
|
2022-11-25 20:11:31 +00:00
|
|
|
# Arbitrary huge trapezoid to cut off the material *in front*
|
|
|
|
# of the inclined screen
|
2022-11-25 15:28:39 +00:00
|
|
|
.placeSketch(cq.Sketch().trapezoid(1000, 1000, 90, mode="a"))
|
|
|
|
.cutBlind(1000)
|
2022-11-25 20:11:31 +00:00
|
|
|
# Cut off viewport hole so we can see the screen
|
2022-11-25 15:28:39 +00:00
|
|
|
.workplaneFromTagged("slanted")
|
|
|
|
.placeSketch(viewport_cutout)
|
|
|
|
.cutBlind(-shell_t)
|
2022-11-25 20:11:31 +00:00
|
|
|
# Make hole for screen assembly so the whole screen fits
|
2022-11-25 15:28:39 +00:00
|
|
|
.workplaneFromTagged("slanted")
|
|
|
|
.workplane(offset=-shell_t, centerOption="CenterOfBoundBox")
|
2022-11-25 21:15:42 +00:00
|
|
|
# Left bezel is wider than right one, so this hole is displaced to the left
|
|
|
|
.center(-3, 0)
|
2022-11-25 15:28:39 +00:00
|
|
|
.placeSketch(screen_cutout)
|
|
|
|
.cutBlind(-scr_thickness)
|
2022-11-25 21:15:42 +00:00
|
|
|
# Trim the top
|
|
|
|
.workplaneFromTagged("mid_height")
|
|
|
|
.workplane(offset=21)
|
|
|
|
.placeSketch(cq.Sketch().trapezoid(1000, 1000, 90, mode="a"))
|
|
|
|
.cutBlind(100)
|
2022-11-25 15:28:39 +00:00
|
|
|
# Make it hollow
|
|
|
|
.faces("<Z")
|
|
|
|
.shell(-2)
|
2022-11-25 20:11:31 +00:00
|
|
|
# Cut hole for the screen board and cables
|
2022-11-25 15:28:39 +00:00
|
|
|
.workplaneFromTagged("slanted")
|
2022-11-25 17:46:30 +00:00
|
|
|
.workplane(offset=-scr_thickness, centerOption="CenterOfBoundBox")
|
2022-11-25 20:11:31 +00:00
|
|
|
.placeSketch(board_cutout)
|
2022-11-25 17:46:30 +00:00
|
|
|
.cutBlind(-5)
|
2022-11-25 21:15:42 +00:00
|
|
|
# Fillet top of the object
|
|
|
|
.edges(">Z and |X").fillet(5)
|
2022-11-25 15:28:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
exporters.export(model(), "screen_mount.stl")
|
|
|
|
|
|
|
|
left_cutout = cq.Sketch().polygon(
|
|
|
|
[(0, 0), (160, 0), (160, -100), (0, -100), (0, 0)],
|
|
|
|
mode="a",
|
|
|
|
)
|
|
|
|
|
|
|
|
right_side = (
|
|
|
|
model()
|
|
|
|
.faces("<Z")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox", offset=3)
|
|
|
|
.center(-width / 2, height / 2)
|
|
|
|
.placeSketch(left_cutout)
|
|
|
|
.cutBlind(-100)
|
2022-11-24 20:45:59 +00:00
|
|
|
)
|
|
|
|
|
2022-11-25 15:28:39 +00:00
|
|
|
exporters.export(right_side, "right_screen_mount.stl")
|
2022-11-24 20:45:59 +00:00
|
|
|
|
2022-11-25 15:28:39 +00:00
|
|
|
left_side = (
|
|
|
|
model()
|
|
|
|
.faces("<Z")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox", offset=3)
|
|
|
|
.center(0, height / 2)
|
|
|
|
.placeSketch(left_cutout)
|
|
|
|
.cutBlind(-100)
|
2022-11-24 20:45:59 +00:00
|
|
|
)
|
|
|
|
|
2022-11-25 15:28:39 +00:00
|
|
|
exporters.export(left_side, "left_screen_mount.stl")
|