133 lines
3.8 KiB
Python
133 lines
3.8 KiB
Python
import cadquery2 as cq
|
|
from cadquery2 import exporters
|
|
|
|
from modelo import (
|
|
kbd_height,
|
|
kbd_width,
|
|
mounting_pillar_positions,
|
|
shell_t,
|
|
ti_depth,
|
|
ti_radius,
|
|
)
|
|
|
|
# Size of the whole object
|
|
width = kbd_width + 2 * shell_t
|
|
height = 59
|
|
thickness = 62 # Will be shorter after construction
|
|
|
|
# Visible screen size
|
|
vis_w = 220
|
|
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")
|
|
|
|
# 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.
|
|
board_cutout = cq.Sketch().trapezoid(
|
|
scr_w + 5,
|
|
scr_h - 10,
|
|
90,
|
|
mode="a",
|
|
)
|
|
|
|
kbd_cable_hole = cq.Sketch().trapezoid(15, 5, 90, mode="a").vertices().fillet(1)
|
|
|
|
mounting_pillars = (
|
|
cq.Sketch()
|
|
.polygon([(0, 0), (width, 0), (width, -12), (0, -12), (0, 0)], mode="a")
|
|
.push(mounting_pillar_positions)
|
|
.circle(ti_radius, mode="s")
|
|
)
|
|
|
|
|
|
def model():
|
|
return (
|
|
cq.Workplane("XY")
|
|
.workplane()
|
|
.tag("mid_height")
|
|
.box(width, height, thickness)
|
|
# The screen goes at a 45 degree angle
|
|
.faces(">Z")
|
|
.transformed(rotate=(45, 0, 0))
|
|
# Move the screen "lower" so it doesn't interfere
|
|
# so much with the back
|
|
.center(0, -2)
|
|
.tag("slanted")
|
|
# Arbitrary huge trapezoid to cut off the material *in front*
|
|
# of the inclined screen
|
|
.placeSketch(cq.Sketch().trapezoid(1000, 1000, 90, mode="a"))
|
|
.cutBlind(1000)
|
|
# 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)
|
|
# Trim the top
|
|
.workplaneFromTagged("mid_height")
|
|
.workplane(offset=21)
|
|
.placeSketch(cq.Sketch().trapezoid(1000, 1000, 90, mode="a"))
|
|
.cutBlind(100)
|
|
# Make it hollow
|
|
.faces("<Z")
|
|
# Can't be exactly shell_t because cq fails
|
|
.shell(-shell_t + 0.01)
|
|
# Cut hole for the screen board and cables
|
|
.workplaneFromTagged("slanted")
|
|
.workplane(offset=-scr_thickness, centerOption="CenterOfBoundBox")
|
|
.placeSketch(board_cutout)
|
|
.cutBlind(-6)
|
|
# Fillet top of the object
|
|
.edges(">Z and |X")
|
|
.fillet(5)
|
|
# Make small hole for the keyboard cable
|
|
.faces(">Y")
|
|
.workplane(offset=-5, centerOption="CenterOfBoundBox")
|
|
.center(-width / 2 + 128, -23)
|
|
.placeSketch(kbd_cable_hole)
|
|
.cutBlind(-1000)
|
|
# Pillars to join with bottom half
|
|
.workplaneFromTagged("mid_height")
|
|
.workplane(offset=-thickness / 2, centerOption="CenterOfBoundBox")
|
|
.center(-width / 2, height / 2)
|
|
.placeSketch(mounting_pillars)
|
|
.extrude(10)
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
print("Exporting")
|
|
exporters.export(model(), "screen_mount.stl")
|
|
|
|
offset_width = -133
|
|
|
|
right_side = (
|
|
model()
|
|
.faces(">X")
|
|
.workplane(centerOption="CenterOfBoundBox", offset=offset_width)
|
|
.split(keepTop=True)
|
|
)
|
|
|
|
exporters.export(right_side, "right_screen_mount.stl")
|
|
|
|
left_side = (
|
|
model()
|
|
.faces(">X")
|
|
.workplane(centerOption="CenterOfBoundBox", offset=offset_width)
|
|
.split(keepBottom=True)
|
|
)
|
|
|
|
exporters.export(left_side, "left_screen_mount.stl")
|