"""Surface-mount slide DIP switch, Omron A6S and A6H sizes. Centred on the origin with the seating plane on the XY plane, the poles in a row along X (pole 1 at -X) and the gull-wing leads out to -Y and +Y. Dimensions from the Omron datasheet for `series`; see the README.""" from steve import Model series = "A6S" # Omron series: A6S (2.54 mm pitch) or A6H (1.27 mm pitch) poles = 4 # number of switches actuator = "flat" # flat, or raised (A6S only: the actuators stand 0.7 above the body) # series: (pitch, body width, height, lead tip to tip, foot length, lead width, raised actuator height, raised actuator length), mm. # Omron A6S-H datasheet (en-a6s.pdf, 2019), Dimensions, page 3; Omron A6H datasheet (en-a6h.pdf, 2019), Dimensions, page 2. A6H prints no lead width or # raised actuator; None there. SERIES = { "A6S": (2.54, 6.2, 3.0, 9.8, 0.7, 0.5, 0.7, 1.0), "A6H": (1.27, 4.5, 1.45, 6.7, 0.6, None, None, None), } # Body length A by number of poles, from the same pages' tables. LENGTH = { "A6S": {1: 3.48, 2: 6.02, 3: 8.56, 4: 11.10, 5: 13.64, 6: 16.18, 7: 18.72, 8: 21.26, 9: 23.80, 10: 26.34}, "A6H": {2: 3.77, 4: 6.31, 6: 8.85, 8: 11.39, 10: 13.93}, } # Proportions, for looks: lead thickness, the body's height above the seating plane, A6H's lead width, and the actuator windows and knobs. LEAD_T = 0.2 STANDOFF = 0.15 A6H_LEAD_W = 0.4 pitch, width, top, span, foot, lead_w, raised_h, raised_l = SERIES[series] lead_w = lead_w or A6H_LEAD_W length = LENGTH[series][poles] first = -(poles - 1) * pitch / 2 model = Model() model.plane("body_plane", on="XY", offset=STANDOFF, name="Body") with model.sketch("body_sketch", on="body_plane", name="Body") as sk: sk.rect("body_rect", (-length / 2, -width / 2), (length / 2, width / 2)) model.extrude("body", "body_sketch", distance=top - STANDOFF, name="Body") model.plane("top_plane", on="XY", offset=top, name="Top") win_w, win_l, depth = 0.45 * pitch, 0.55 * width, 0.25 * (top - STANDOFF) with model.sketch("windows", on="top_plane", name="Actuator windows") as sk: for i in range(poles): x = first + i * pitch sk.rect(f"window_{i}", (x - win_w / 2, -win_l / 2), (x + win_w / 2, win_l / 2)) model.extrude("window_cut", "windows", distance=-depth, op="cut", name="Actuator windows") knob_h = depth + (raised_h if actuator == "raised" and raised_h else 0.0) knob_l = 0.4 * win_l model.plane("knob_plane", on="XY", offset=top - depth, name="Actuators") with model.sketch("knobs", on="knob_plane", name="Actuators") as sk: for i in range(poles): x = first + i * pitch # switches drawn in the OFF position, toward -Y sk.rect(f"knob_{i}", (x - win_w / 2 + 0.05, -win_l / 2), (x + win_w / 2 - 0.05, -win_l / 2 + knob_l)) model.extrude("knobs_body", "knobs", distance=knob_h, name="Actuators") arm_z = top / 2 for tag, side in (("low", -1), ("high", 1)): y_out, y_body, y_bend = side * span / 2, side * width / 2, side * (span / 2 - foot) with model.sketch(f"feet_{tag}", on="XY", name="Leads") as sk: for i in range(poles): x = first + i * pitch sk.rect(f"foot_{tag}_{i}", (x - lead_w / 2, min(y_bend, y_out)), (x + lead_w / 2, max(y_bend, y_out))) model.extrude(f"feet_{tag}_body", f"feet_{tag}", distance=LEAD_T, name="Leads") model.plane(f"arm_plane_{tag}", on="XY", offset=arm_z, name="Leads") with model.sketch(f"arms_{tag}", on=f"arm_plane_{tag}", name="Leads") as sk: for i in range(poles): x = first + i * pitch sk.rect(f"arm_{tag}_{i}", (x - lead_w / 2, min(y_body, y_bend) - LEAD_T / 2), (x + lead_w / 2, max(y_body, y_bend) + LEAD_T / 2)) model.extrude(f"arms_{tag}_body", f"arms_{tag}", distance=LEAD_T, name="Leads") with model.sketch(f"legs_{tag}", on="XY", name="Leads") as sk: for i in range(poles): x = first + i * pitch sk.rect(f"leg_{tag}_{i}", (x - lead_w / 2, y_bend - LEAD_T / 2), (x + lead_w / 2, y_bend + LEAD_T / 2)) model.extrude(f"legs_{tag}_body", f"legs_{tag}", distance=arm_z + LEAD_T, name="Leads") model.material("pla", color="#2b2d31") result = model.result()