-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdpad.py
More file actions
49 lines (41 loc) · 1.57 KB
/
Copy pathdpad.py
File metadata and controls
49 lines (41 loc) · 1.57 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
38
39
40
41
42
43
44
45
46
47
48
49
# ============================================================
# RetroPad - D-Pad
# Description : build123d script to recreate the D-Pad part
# Reference : https://github.com/jtgans/RetroPad/tree/master/case
# Status : Work in Progress
# ============================================================
from build123d import *
from ocp_vscode import show
# ── Dimensions (measured from reference STL via MeshLab) ──
cyl_r = 16.03 # cylinder radius
cyl_h = 8 # cylinder height
arm_w = 10 # width of each plus arm
arm_l = 28 # length of each plus arm
cross_h = 4 # height of cross (top and bottom)
# ── Build the D-Pad ──
with BuildPart() as dpad:
# Step 1: Base cylinder
Cylinder(radius=cyl_r, height=cyl_h)
# Step 2: Plus shape on TOP
with BuildSketch(Plane.XY.offset(cyl_h/2)):
Rectangle(arm_l, arm_w)
Rectangle(arm_w, arm_l)
extrude(amount=cross_h)
# Step 3: Plus shape on BOTTOM
with BuildSketch(Plane.XY.offset(-cyl_h/2)):
Rectangle(arm_l, arm_w)
Rectangle(arm_w, arm_l)
extrude(amount=-cross_h)
# Step 4: Chamfer all top edges of the plus
top_z = dpad.part.faces().sort_by(Axis.Z)[-1].center().Z
top_edges = dpad.part.edges().filter_by_position(
Axis.Z,
minimum=top_z - 0.1,
maximum=top_z + 0.1
)
chamfer(top_edges, length=1)
# ── Show in OCP Viewer ──
show(dpad)
print(f"Generated Volume : {dpad.part.volume:.3f} mm³")
print(f"Target Volume : 7947.733 mm³")
print(f"Difference : {dpad.part.volume - 7947.733:.3f} mm³")