"""Through-hole pin header, 2.54 mm and 2.00 mm pitch, one or two rows, straight or right-angle (2.54 mm only). Pin 1 is at the origin, the row along +X. Straight: the second row along +Y, the insulator's underside on the XY plane, the mating posts up. Right-angle: the second row's tails along -Y, the insulator standing on the XY plane, the mating posts along +Y. The tails go 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 style = "straight" # straight or right-angle 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)} # Right-angle, 2.54: Samtec TSW lead style -08-RA, same page: post out from the insulator C 5.84, tail below the insulator E 2.29, tail to the insulator D 1.52, # insulator height 3.02 (one row) and 5.56 (two rows). The insulator's depth is taken as the straight header's 2.54 high. RIGHT_ANGLE = (5.84, 2.29, 1.52, 3.02, 5.56) 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() if style == "right-angle": out, drop, back, high_one, high_two = RIGHT_ANGLE high = high_one if rows == 1 else high_two with model.sketch("body_sketch", on="XY", name="Insulator") as sk: sk.rect("body_outline", (x0, back), (x0 + length, back + body_h)) model.extrude("body", "body_sketch", distance=high, name="Insulator") if detail == "full": rise = (high - (rows - 1) * pitch) / 2 for row in range(rows): z = rise + row * pitch y_tail = -row * pitch model.plane(f"run_plane_{row}", on="XZ", offset=-y_tail + post / 2, name="Posts") with model.sketch(f"post_sketch_{row}", on=f"run_plane_{row}", name="Posts") as sk: for i in range(pins): sk.rect(f"post_{row}_{i}", (i * pitch - post / 2, z - post / 2), (i * pitch + post / 2, z + post / 2)) model.extrude(f"posts_{row}", f"post_sketch_{row}", distance=-(back + body_h + out - y_tail + post / 2), name="Posts") model.plane(f"tail_plane_{row}", on="XY", offset=-drop, name="Tails") with model.sketch(f"tail_sketch_{row}", on=f"tail_plane_{row}", name="Tails") as sk: for i in range(pins): sk.rect(f"tail_{row}_{i}", (i * pitch - post / 2, y_tail - post / 2), (i * pitch + post / 2, y_tail + post / 2)) model.extrude(f"tails_{row}", f"tail_sketch_{row}", distance=drop + z + post / 2, name="Tails") else: 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()