-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.py
More file actions
37 lines (29 loc) · 1.35 KB
/
Copy pathbutton.py
File metadata and controls
37 lines (29 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# ============================================================
# RetroPad - Button
# Description : build123d script to recreate the Button part
# Reference : https://github.com/jtgans/RetroPad/tree/master/case
# ============================================================
from build123d import *
from ocp_vscode import show
# ── Dimensions (measured from reference STL via MeshLab) ──
r1, h1 = 9.5 / 2, 15.5 # cylinder radius and height
w, l, h = 1.20, 1.8, 5.5 # clip width, length, height
# ── Build the Button ──
with BuildPart() as button:
# Step 1: Main cylinder body
Cylinder(radius=r1, height=h1)
# Step 2: Add 4 rectangular clips around the base using PolarLocations
with Locations((0, 0, -h1/2)):
with PolarLocations(radius=r1, count=4):
Box(l, w, h, align=(Align.CENTER, Align.CENTER, Align.MIN))
# Step 3: Chamfer the top edge
chamfer(button.part.edges().sort_by(Axis.Z)[-1], length=1)
# ── Show in OCP Viewer ──
show(button)
# ── Export ──
export_stl(button.part, "generated/button_generated.stl")
export_step(button.part, "generated/button_generated.step")
print(f"Generated Volume : {button.part.volume:.3f} mm³")
print(f"Target Volume : 1150.783 mm³")
print(f"Difference : {button.part.volume - 1150.783:.3f} mm³")
print("✅ Button exported successfully!")