Create STL for case pieces too

This commit is contained in:
Roberto Alsina 2022-07-24 10:30:22 -03:00
parent 5dd7b5578f
commit d0c1a2cdae

View File

@ -37,54 +37,72 @@ back_reinforcement = (
threaded_inserts = cq.Sketch().rarray(width / 8, 0, 4, 1).circle(ti_radius, mode="a")
# Case for the screen
case = (
# Basic filleted box shape
cq.Workplane("bottom")
.lineTo(-width, 0)
.lineTo(-width, height)
.lineTo(0, height)
.close()
.extrude(length)
.faces(">X")
.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)
# Cutout for the circuit board
.faces("<Z")
.workplane(centerOption="CenterOfBoundBox")
.center(width / 2 - 27.5, 0)
.placeSketch(board_cutout)
.cutBlind(-shell_t)
# 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)
.extrude(1 + 1 + ti_depth - shell_t)
.faces("<Z")
.workplane(centerOption="CenterOfBoundBox")
.placeSketch(threaded_inserts)
.cutBlind(-ti_depth)
)
exporters.export(case, "case.stl")
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)
.faces(">X")
.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)
# Cutout for the circuit board
.faces("<Z")
.workplane(centerOption="CenterOfBoundBox")
.center(width / 2 - 27.5, 0)
.placeSketch(board_cutout)
.cutBlind(-shell_t)
# 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)
.extrude(1 + 1 + ti_depth - shell_t)
.faces("<Z")
.workplane(centerOption="CenterOfBoundBox")
.placeSketch(threaded_inserts)
.cutBlind(-ti_depth)
)
full_case = case()
exporters.export(full_case, "case.stl")
top_case = (case()
.faces(">X")
.workplane(offset=-width/2)
.split(keepTop=True)
)
exporters.export(top_case, "case_1.stl")
bottom_case = (case()
.faces(">X")
.workplane(offset=-width/2)
.split(keepBottom=True)
)
exporters.export(bottom_case, "case_2.stl")