"""Key plate of the Adafruit MacroPad RP2040 kit (Adafruit product 5128): a 59.69 x 78.74 mm plate with rounded corners and a 3 x 4 grid of 14.224 mm square key switch cut-outs at 19.05 mm (0.75 in) pitch. The plate lies on the XY plane from z = 0, centred on the origin, the long side along Y. Measured from Adafruit's published model (MIT); see the README. """ from steve import Model thickness = 1.57 # mm Plate thickness # mm, measured on Adafruit's model "5128 MacroPad RP2040-Keyplate.step" (its mid-thickness section, every edge read): PLATE = { "width": 59.69, # X (2.35 in) "length": 78.74, # Y (3.1 in) "corner_r": 2.54, # outside corner radius (0.1 in) "cutout": 14.224, # square switch cut-out (0.56 in) "pitch": 19.05, # cut-out centre pitch, both ways (0.75 in) "columns": 3, # across X "rows": 4, # along Y } p = PLATE w, l, r = p["width"], p["length"], p["corner_r"] x, y = w / 2, l / 2 model = Model() with model.sketch("plate_sketch", on="XY", name="Plate") as sk: sk.line("bottom", (-x + r, -y), (x - r, -y)) sk.arc("corner_1", (x - r, -y + r), r, 270, 360) sk.line("right", (x, -y + r), (x, y - r)) sk.arc("corner_2", (x - r, y - r), r, 0, 90) sk.line("top", (x - r, y), (-x + r, y)) sk.arc("corner_3", (-x + r, y - r), r, 90, 180) sk.line("left", (-x, y - r), (-x, -y + r)) sk.arc("corner_4", (-x + r, -y + r), r, 180, 270) model.extrude("plate", "plate_sketch", distance=thickness, name="Plate") with model.sketch("cutout_sketch", on="XY", name="Switch cut-outs") as sk: for i in range(p["columns"]): for j in range(p["rows"]): cx = (i - (p["columns"] - 1) / 2) * p["pitch"] cy = (j - (p["rows"] - 1) / 2) * p["pitch"] sk.center_rect(f"cutout_{i}_{j}", (cx, cy), p["cutout"], p["cutout"]) model.extrude("cutouts", "cutout_sketch", distance=thickness, op="cut", name="Switch cut-outs") result = model.result()