2022-07-22 01:00:45 +00:00
|
|
|
import cadquery2 as cq
|
|
|
|
from cadquery2 import exporters
|
|
|
|
|
2022-07-22 21:23:27 +00:00
|
|
|
from parameters import *
|
2022-07-22 11:05:59 +00:00
|
|
|
|
2022-07-22 01:00:45 +00:00
|
|
|
screen_cutout = (
|
2022-07-22 10:52:26 +00:00
|
|
|
cq.Sketch().trapezoid(screen_w, screen_l, 90, mode="a").reset().vertices().fillet(1)
|
2022-07-22 01:00:45 +00:00
|
|
|
)
|
|
|
|
|
2022-07-22 13:13:21 +00:00
|
|
|
board_cutout = (
|
|
|
|
cq.Sketch().trapezoid(55, 50, 90, mode="a").reset().vertices("<X").fillet(5)
|
|
|
|
)
|
2022-07-22 13:11:25 +00:00
|
|
|
|
2022-07-24 14:06:50 +00:00
|
|
|
plug_channel_cutout = cq.Sketch().trapezoid(45, 6, 90, mode="a").reset().vertices("<X")
|
2022-07-24 13:29:07 +00:00
|
|
|
|
2022-07-24 14:06:50 +00:00
|
|
|
cable_relief = cq.Sketch().trapezoid(width - 2 * shell_t, 30, 90)
|
2022-07-22 17:38:08 +00:00
|
|
|
|
2022-07-24 14:06:50 +00:00
|
|
|
break_depth = 20
|
2022-07-22 02:00:37 +00:00
|
|
|
segment_breaks_top = (
|
2022-07-22 10:52:26 +00:00
|
|
|
cq.Sketch()
|
2022-07-22 16:01:44 +00:00
|
|
|
.rarray(1, length, 1, 1)
|
2022-07-24 14:06:50 +00:00
|
|
|
.trapezoid(width / 3, break_depth, 110, mode="a")
|
2022-07-22 10:52:26 +00:00
|
|
|
.reset()
|
|
|
|
.vertices()
|
2022-07-22 16:01:44 +00:00
|
|
|
.fillet(5)
|
2022-07-22 02:00:37 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
segment_breaks_bottom = (
|
2022-07-22 10:52:26 +00:00
|
|
|
cq.Sketch()
|
2022-07-22 16:01:44 +00:00
|
|
|
.rarray(1, length, 1, 1)
|
2022-07-24 14:06:50 +00:00
|
|
|
.trapezoid(width / 3, break_depth, 70, mode="a")
|
2022-07-22 10:52:26 +00:00
|
|
|
.reset()
|
|
|
|
.vertices()
|
2022-07-22 16:01:44 +00:00
|
|
|
.fillet(5)
|
2022-07-22 10:52:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
back_reinforcement = (
|
2022-07-24 14:06:50 +00:00
|
|
|
cq.Sketch().trapezoid(width / 2, length-break_depth, 90, mode="a").reset().vertices().fillet(2)
|
2022-07-22 10:52:26 +00:00
|
|
|
)
|
|
|
|
|
2022-07-22 16:01:44 +00:00
|
|
|
threaded_inserts = cq.Sketch().rarray(width / 8, 0, 4, 1).circle(ti_radius, mode="a")
|
2022-07-22 01:00:45 +00:00
|
|
|
|
2022-07-24 13:30:22 +00:00
|
|
|
|
|
|
|
def case():
|
|
|
|
# Case for the screen
|
|
|
|
return (
|
|
|
|
# Basic filleted box shape
|
|
|
|
cq.Workplane("bottom")
|
|
|
|
.lineTo(-width, 0)
|
|
|
|
.lineTo(-width, height)
|
|
|
|
.lineTo(0, height)
|
|
|
|
.close()
|
|
|
|
.extrude(length)
|
|
|
|
.shell(-shell_t)
|
|
|
|
.edges("|X")
|
|
|
|
.fillet(fillet_s)
|
|
|
|
# Cutout visible screen area from top face
|
|
|
|
.faces(">Z")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
|
|
|
.center((width - screen_w) / 2 - screen_left_margin, 0)
|
|
|
|
.placeSketch(screen_cutout)
|
|
|
|
.cutBlind(-shell_t)
|
|
|
|
# Cutout for segment breaks
|
|
|
|
.faces(">Z")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
|
|
|
.center(0, length / 2)
|
|
|
|
.placeSketch(segment_breaks_top)
|
|
|
|
.cutBlind(-1000)
|
|
|
|
.center(0, -length)
|
|
|
|
.placeSketch(segment_breaks_bottom)
|
|
|
|
.cutBlind(-1000)
|
|
|
|
# Make some room for the ribbon cable
|
|
|
|
.faces("<Z[-2]")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
|
|
|
.placeSketch(cable_relief)
|
|
|
|
.cutBlind(-1)
|
|
|
|
# Back reinforcement with holes for threaded inserts
|
|
|
|
.faces("<Z")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
|
|
|
.placeSketch(back_reinforcement)
|
2022-07-24 14:06:50 +00:00
|
|
|
.extrude(7 + ti_depth - shell_t)
|
2022-07-24 13:30:22 +00:00
|
|
|
.faces("<Z")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
|
|
|
.placeSketch(threaded_inserts)
|
|
|
|
.cutBlind(-ti_depth)
|
2022-07-24 14:06:50 +00:00
|
|
|
# Cutout room for plugs to slide in and be exposed
|
|
|
|
.faces(">X")
|
|
|
|
.workplane(centerOption="CenterOfBoundBox")
|
|
|
|
.center(0, -5)
|
|
|
|
.placeSketch(plug_channel_cutout)
|
|
|
|
.cutBlind(-width / 2)
|
2022-07-24 13:30:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
full_case = case()
|
|
|
|
exporters.export(full_case, "case.stl")
|
|
|
|
|
2022-07-24 13:31:48 +00:00
|
|
|
top_case = case().faces(">X").workplane(offset=-width / 2).split(keepTop=True)
|
2022-07-24 13:30:22 +00:00
|
|
|
exporters.export(top_case, "case_1.stl")
|
2022-07-22 01:00:45 +00:00
|
|
|
|
2022-07-24 13:31:48 +00:00
|
|
|
bottom_case = case().faces(">X").workplane(offset=-width / 2).split(keepBottom=True)
|
2022-07-24 13:30:22 +00:00
|
|
|
exporters.export(bottom_case, "case_2.stl")
|