"""PCB screw terminal block, Phoenix Contact MKDS 1,5 type, 5.0 or 5.08 mm pitch, 2 to 16 positions. Pin 1 is at the origin, the row along +X, the housing on the XY plane, the wire entries facing -Y, the screws on top, the solder pins down through the board. Dimensions from Phoenix Contact's data sheet in the README.""" from steve import Model pitch = 5.08 # mm Pitch positions = 2 # Positions detail = "full" # full: wire entries, screw heads and solder pins; simple: the housing's outline # Phoenix Contact data sheet, PCB terminal block MKDS 1,5/ 2-5,08 (1715721), Dimensions p. 4 and Dimensional drawing p. 8: width a + pitch, height 13.8 above # the board, length 9.8, solder pins 3.5 long, 0.9 x 0.9, 4.6 from the wire-entry face. The drawing gives the same housing for 5.0 and 5.08 mm pitch. HEIGHT, LENGTH, PIN_LENGTH, PIN, PIN_FROM_FRONT = 13.8, 9.8, 3.5, 0.9, 4.6 if pitch not in (5.0, 5.08) or not 2 <= positions <= 16: raise ValueError("MKDS 1,5 comes in 5.0 and 5.08 mm pitch, 2 to 16 positions.") width = positions * pitch x0 = -pitch / 2 front = -PIN_FROM_FRONT # the side profile: the step at the top of the wire-entry face and the sloped back are proportions, for looks profile = [(front, 0), (front + LENGTH, 0), (front + LENGTH, 0.72 * HEIGHT), (front + 0.75 * LENGTH, HEIGHT), (front + 0.25 * LENGTH, HEIGHT), (front + 0.25 * LENGTH, 0.8 * HEIGHT), (front, 0.8 * HEIGHT)] model = Model() model.plane("side_plane", on="YZ", offset=x0, name="Side") with model.sketch("body_sketch", on="side_plane", name="Housing") as sk: sk.polyline("body_outline", profile, closed=True) model.extrude("body", "body_sketch", distance=width, name="Housing") if detail == "full": entry, screw = 0.6 * pitch, 0.55 * pitch # the wire entry and screw head sizes are proportions, for looks model.plane("front_plane", on="XZ", offset=-front, name="Wire entries") with model.sketch("entries_sketch", on="front_plane", name="Wire entries") as sk: for i in range(positions): sk.rect(f"entry_{i}", (i * pitch - entry / 2, 0.25 * HEIGHT), (i * pitch + entry / 2, 0.25 * HEIGHT + entry)) model.extrude("entries", "entries_sketch", distance=-0.55 * LENGTH, op="cut", name="Wire entries") model.plane("top_plane", on="XY", offset=HEIGHT, name="Top") with model.sketch("screws_sketch", on="top_plane", name="Screw openings") as sk: for i in range(positions): sk.circle(f"screw_{i}", (i * pitch, front + 0.5 * LENGTH), screw / 2) model.extrude("screws", "screws_sketch", distance=-0.15 * HEIGHT, op="cut", name="Screw openings") model.plane("pin_plane", on="XY", offset=-PIN_LENGTH, name="Solder pins") with model.sketch("pins_sketch", on="pin_plane", name="Solder pins") as sk: for i in range(positions): sk.rect(f"pin_{i}", (i * pitch - PIN / 2, -PIN / 2), (i * pitch + PIN / 2, PIN / 2)) model.extrude("pins", "pins_sketch", distance=PIN_LENGTH + 1, name="Solder pins") model.material("pa6", color="#2f7d4a") result = model.result()