"""Through-hole DIP switch, CTS Series 194/195 (side-actuated, "piano" keys). Pin 1 is at the origin, the switches' pins 1 to N along +X in the row nearest the keys, their other pins in the row 7.62 towards +Y; the keys stick out of the body's -Y face. The body stands on the board (XY plane) and the pins go down through it. Dimensions from CTS's data sheet; see the README.""" from steve import Model series = "194" # CTS series: 194 (gold-plated contacts) or 195 (tin-plated); the same size positions = 4 # number of switches: 2 to 10, or 12 # series: (pitch, rows apart, body depth across the rows, height above the board, pin length below it, pin across X, pin across Y, # key width, key out of the body's face). # CTS Series 194/195 Data Sheet, Through Hole DIP Switch, 06/14/17, page 2-2 (Chip and Dip's copy, static.chipdip.ru DOC040834963): # 2.54 typ., 7.62 +0.38/-0.13, 9.78 +-0.25, 7.90 from the mounting surface, 3.81 +0.25/-0.51, terminals 0.48 +-0.08 and 0.20 +-0.08, # keys 1.52 wide, 1.14 REF (M, medium height actuator). SERIES = { "194": (2.54, 7.62, 9.78, 7.90, 3.81, 0.48, 0.20, 1.52, 1.14), "195": (2.54, 7.62, 9.78, 7.90, 3.81, 0.48, 0.20, 1.52, 1.14), } # Overall length "A" by number of positions, the same page's table (194/195-2MS to -12MS). LENGTH = {2: 7.26, 3: 9.80, 4: 12.34, 5: 14.88, 6: 17.42, 7: 19.96, 8: 22.50, 9: 25.04, 10: 27.58, 12: 32.66} # Proportions, for looks (the sheet doesn't dimension them): the keys' height, from the body's top down, as drawn in the front view. KEY_H = 3.2 if positions not in LENGTH: raise ValueError(f"CTS 194/195 come with {', '.join(map(str, LENGTH))} positions, not {positions}") pitch, rows, depth, height, tail, pin_x, pin_y, key_w, key_out = SERIES[series] length = LENGTH[positions] # The body is centred on the pins both ways. x_mid = (positions - 1) * pitch / 2 y_mid = rows / 2 front = y_mid - depth / 2 model = Model() model.box("body", length, depth, height, at=(x_mid, y_mid, height / 2), op="new", body="body_body", name="Body") keys = [] for i in range(positions): x = i * pitch model.box(f"key_{i + 1}", key_w, key_out, KEY_H, at=(x, front - key_out / 2, height - KEY_H / 2), op="new", body=f"key_{i + 1}_body", name=f"Key {i + 1}") keys.append(f"key_{i + 1}_body") pins = [] for i in range(positions): for row, number in ((0.0, i + 1), (rows, 2 * positions - i)): model.box(f"pin_{number}", pin_x, pin_y, tail, at=(i * pitch, row, -tail / 2), op="new", body=f"pin_{number}_body", name=f"Pin {number}") pins.append(f"pin_{number}_body") # Materials, for looks and a rough mass: the sheet names UL 94V-0 plastics (pa6 here) and tin-plated terminals (copper here). model.material("pa6", bodies=["body_body", *keys], color="#1d1e20") model.material("copper", bodies=pins, color="#c9cbc8") result = model.result()