"""Straight through-hole pin header, 2.54 mm and 2.00 mm pitch, one or two rows. Pin 1 is at the origin, the row along +X, the second row along +Y; the insulator's underside is on the XY plane, the posts' mating end up, the tails down through the board. Dimensions in the README.""" from steve import Model pitch = 2.54 # mm Pitch rows = 1 # Rows pins = 8 # Pins per row detail = "full" # full: square posts and notched insulator; simple: one block per row, with no posts # pitch: (above the insulator C, insulator height, tail B, one-row width, two-row width, post square). # 2.54: Samtec TSW lead style -07, catalogue page TSW/HTSW (F-226), A 10.92, B 2.54, C 5.84, widths 2.48 and 5.02, post .025 in. # 2.00: Samtec TMM lead style -02, catalogue page TMM (F-226), A 8.20, B 3.70, C 3.00, body 1.50, widths 1.97 and 3.94. The page doesn't # print the post size, so 0.50 here is a proportion of the pitch, for looks. SIZES = {2.54: (5.84, 2.54, 2.54, 2.48, 5.02, 0.64), 2.0: (3.00, 1.50, 3.70, 1.97, 3.94, 0.50)} above, body_h, tail, one, two, post = SIZES[pitch] width = one if rows == 1 else two length = pitch * pins y0 = (rows - 1) * pitch / 2 - width / 2 x0 = -pitch / 2 notch = 0.12 * pitch # the V between pins, for looks outline = [(x0, y0)] for i in range(1, pins): outline += [(x0 + i * pitch - notch, y0), (x0 + i * pitch, y0 + notch), (x0 + i * pitch + notch, y0)] outline += [(x0 + length, y0), (x0 + length, y0 + width)] for i in range(pins - 1, 0, -1): outline += [(x0 + i * pitch + notch, y0 + width), (x0 + i * pitch, y0 + width - notch), (x0 + i * pitch - notch, y0 + width)] outline += [(x0, y0 + width)] model = Model() with model.sketch("body_sketch", on="XY", name="Insulator") as sk: if detail == "full": sk.polyline("body_outline", outline, closed=True) else: sk.rect("body_outline", (x0, y0), (x0 + length, y0 + width)) model.extrude("body", "body_sketch", distance=body_h if detail == "full" else body_h + above, name="Insulator") if detail == "full": model.plane("tail_plane", on="XY", offset=-tail, name="Tail end") with model.sketch("posts_sketch", on="tail_plane", name="Posts") as sk: for row in range(rows): for i in range(pins): x, y = i * pitch, row * pitch sk.rect(f"post_{row}_{i}", (x - post / 2, y - post / 2), (x + post / 2, y + post / 2)) model.extrude("posts", "posts_sketch", distance=tail + body_h + above, name="Posts") model.material("steel-generic", color="#2b2b2d") result = model.result()