cad_models/laptop_holder.py

37 lines
1.2 KiB
Python

# /// script
# requires-python = ">=3.14"
# dependencies = ["ocp_vscode", "build123d"]
# ///
from build123d import *
from ocp_vscode import *
### USER INPUTS ###
base_thickness = 25.4 * MM
wall_thickness = 9 * MM
slots = [i * MM for i in [22, 22, 20, 20]]
slot_height = 60 * MM
width = 355.7 / 3 * MM # width of macbook pro
###################
with BuildPart() as holder: # noqa: SIM117
with BuildSketch() as sketch:
length = wall_thickness * (len(slots) + 1) + sum(slots)
height = slot_height + base_thickness
Rectangle(length, height)
offset = wall_thickness
for slot in slots:
with Locations((offset - length / 2, base_thickness - height / 2)):
Rectangle(
slot, slot_height, mode=Mode.SUBTRACT, align=(Align.MIN, Align.MIN)
)
Circle(slot / 2, mode=Mode.SUBTRACT, align=(Align.MIN, Align.CENTER))
offset += wall_thickness + slot
extrude(amount=width)
fillet(
holder.edges().group_by(Axis.Y)[-1].filter_by(Axis.Z),
radius=wall_thickness / 2.5,
)
show(holder)
export_stl(holder.part, "laptop_holder.stl")