2022-11-24 20:45:59 +00:00
|
|
|
import cadquery2 as cq
|
|
|
|
from cadquery2 import exporters
|
|
|
|
|
2022-11-28 18:09:49 +00:00
|
|
|
from modelo import (
|
|
|
|
kbd_height,
|
|
|
|
kbd_width,
|
|
|
|
mounting_pillar_positions,
|
|
|
|
shell_t,
|
|
|
|
ti_depth,
|
|
|
|
ti_radius,
|
|
|
|
)
|
2022-11-24 20:45:59 +00:00
|
|
|
|
|
|
|
# Size of the whole object
|
|
|
|
width = kbd_width + 2 * shell_t
|
2023-01-27 19:11:28 +00:00
|
|
|
height = 66
|
2023-01-27 18:32:04 +00:00
|
|
|
height_bottom = 59
|
2023-01-27 19:11:28 +00:00
|
|
|
thickness = 48 # Will be shorter after construction
|
2022-11-24 20:45:59 +00:00
|
|
|
|
|
|
|
# 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")
|
|
|
|
|
2023-01-27 18:32:04 +00:00
|
|
|
# Screen angle
|
2023-01-27 19:11:28 +00:00
|
|
|
scr_angle = 20
|
2023-01-27 18:32:04 +00:00
|
|
|
|
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",
|
|
|
|
)
|
|
|
|
|
2023-01-27 18:32:04 +00:00
|
|
|
kbd_cable_hole = cq.Sketch().trapezoid(20, 9, 90, mode="a").vertices().fillet(1)
|
2022-11-28 14:26:23 +00:00
|
|
|
|
2022-12-02 13:04:23 +00:00
|
|
|
# The last mounting pillar is handled specially
|
|
|
|
x, y = mounting_pillar_positions[-1]
|
2022-11-28 18:09:49 +00:00
|
|
|
mounting_pillars = (
|
|
|
|
cq.Sketch()
|
2022-11-30 10:43:14 +00:00
|
|
|
.polygon([(0, 0), (width, 0), (width, -12), (0, -12), (0, 0)], mode="a")
|
2022-12-02 13:04:23 +00:00
|
|
|
.polygon(
|
|
|
|
[(x - 6, y - 6), (x - 6, y + 6), (x + 6, y + 6), (x + 6, y - 6), (x - 6, y - 6)]
|
|
|
|
)
|
2022-11-28 18:09:49 +00:00
|
|
|
.push(mounting_pillar_positions)
|
|
|
|
.circle(ti_radius, mode="s")
|
|
|
|
)
|
|
|
|
|
2022-11-25 20:11:31 +00:00
|
|
|
|
2022-11-25 15:28:39 +00:00
|
|
|
def model():
|
|
|
|
return (
|
|
|
|
cq.Workplane("XY")
|
2022-11-28 14:26:23 +00:00
|
|
|
.workplane()
|
|
|
|
.tag("mid_height")
|
2022-11-28 18:09:49 +00:00
|
|
|
.box(width, height, thickness)
|
2023-01-27 18:32:04 +00:00
|
|
|
# The screen goes rotated
|
2022-11-25 15:28:39 +00:00
|
|
|
.faces(">Z")
|
2023-01-27 18:32:04 +00:00
|
|
|
.transformed(rotate=(scr_angle, 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 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)
|
2023-01-27 18:32:04 +00:00
|
|
|
# Make bottom smaller to fit with base
|
|
|
|
.faces(">X")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
|
|
|
.center(-height / 2, -thickness / 2)
|
|
|
|
.placeSketch(
|
2023-01-27 18:43:54 +00:00
|
|
|
cq.Sketch()
|
|
|
|
.polygon(
|
2023-01-27 18:32:04 +00:00
|
|
|
[
|
|
|
|
(height_bottom, 0),
|
2023-01-27 18:43:54 +00:00
|
|
|
(height_bottom, thickness / 3),
|
2023-01-27 19:11:28 +00:00
|
|
|
(height, thickness - 21),
|
2023-01-27 18:43:54 +00:00
|
|
|
(height, thickness),
|
|
|
|
(height + 5, thickness + 5),
|
|
|
|
(height + 5, 0),
|
2023-01-27 18:32:04 +00:00
|
|
|
(height_bottom, 0),
|
|
|
|
]
|
|
|
|
)
|
2023-01-27 18:43:54 +00:00
|
|
|
.vertices()
|
|
|
|
.fillet(3)
|
2023-01-27 18:32:04 +00:00
|
|
|
)
|
|
|
|
.cutBlind(-1000)
|
2023-01-27 20:01:37 +00:00
|
|
|
# Fillet top of the object
|
|
|
|
.edges("|X and >Z")
|
|
|
|
.fillet(3)
|
|
|
|
# Cut off viewport hole so we can see the screen
|
|
|
|
.workplaneFromTagged("slanted")
|
|
|
|
.placeSketch(viewport_cutout)
|
|
|
|
.cutBlind(-shell_t)
|
|
|
|
# Make hole for screen assembly so the whole screen fits
|
|
|
|
.workplaneFromTagged("slanted")
|
|
|
|
.workplane(offset=-shell_t, centerOption="CenterOfBoundBox")
|
|
|
|
# Left bezel is wider than right one, so this hole is displaced to the left
|
|
|
|
.center(-3, 0)
|
|
|
|
.placeSketch(screen_cutout)
|
|
|
|
.cutBlind(-scr_thickness)
|
2022-11-25 15:28:39 +00:00
|
|
|
# Make it hollow
|
|
|
|
.faces("<Z")
|
2022-11-28 18:09:49 +00:00
|
|
|
# Can't be exactly shell_t because cq fails
|
|
|
|
.shell(-shell_t + 0.01)
|
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-28 15:19:56 +00:00
|
|
|
.cutBlind(-6)
|
2022-11-28 14:26:23 +00:00
|
|
|
# Make small hole for the keyboard cable
|
|
|
|
.faces(">Y")
|
|
|
|
.workplane(offset=-5, centerOption="CenterOfBoundBox")
|
2023-01-27 20:01:37 +00:00
|
|
|
.center(-width / 2 + 175, -25)
|
2022-11-28 14:26:23 +00:00
|
|
|
.placeSketch(kbd_cable_hole)
|
|
|
|
.cutBlind(-1000)
|
2022-11-28 18:09:49 +00:00
|
|
|
# Pillars to join with bottom half
|
|
|
|
.workplaneFromTagged("mid_height")
|
|
|
|
.workplane(offset=-thickness / 2, centerOption="CenterOfBoundBox")
|
2023-01-27 18:32:04 +00:00
|
|
|
.center(-width / 2, height_bottom - height / 2)
|
2022-11-28 18:09:49 +00:00
|
|
|
.placeSketch(mounting_pillars)
|
|
|
|
.extrude(10)
|
2022-11-25 15:28:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2022-11-30 17:29:42 +00:00
|
|
|
if __name__ == "__main__":
|
2022-11-24 20:45:59 +00:00
|
|
|
|
2022-12-01 18:20:57 +00:00
|
|
|
print("Exporting")
|
2022-11-30 17:29:42 +00:00
|
|
|
exporters.export(model(), "screen_mount.stl")
|
2022-11-24 20:45:59 +00:00
|
|
|
|
2023-01-27 19:11:28 +00:00
|
|
|
offset_width = -width / 2
|
2022-12-01 18:20:57 +00:00
|
|
|
|
2022-11-30 17:29:42 +00:00
|
|
|
right_side = (
|
|
|
|
model()
|
|
|
|
.faces(">X")
|
2022-12-01 18:20:57 +00:00
|
|
|
.workplane(centerOption="CenterOfBoundBox", offset=offset_width)
|
2022-11-30 17:29:42 +00:00
|
|
|
.split(keepTop=True)
|
|
|
|
)
|
|
|
|
|
|
|
|
exporters.export(right_side, "right_screen_mount.stl")
|
|
|
|
|
|
|
|
left_side = (
|
|
|
|
model()
|
|
|
|
.faces(">X")
|
2022-12-01 18:20:57 +00:00
|
|
|
.workplane(centerOption="CenterOfBoundBox", offset=offset_width)
|
2022-11-30 17:29:42 +00:00
|
|
|
.split(keepBottom=True)
|
|
|
|
)
|
2022-11-24 20:45:59 +00:00
|
|
|
|
2022-11-30 17:29:42 +00:00
|
|
|
exporters.export(left_side, "left_screen_mount.stl")
|