"""JST XH shrouded header, 2.5 mm pitch, top entry, through-hole: B2B-XH-A to B20B-XH-A. Pin 1 is at the origin, the row along +X, the housing's underside on the XY plane, its opening up, the posts' tails down through the board. Dimensions from JST's catalogue page in the README.""" from steve import Model circuits = 4 # Circuits detail = "full" # full: the shroud's opening and the posts; simple: a plain block # JST XH connector catalogue, Through-hole type shrouded header, Top entry type, p. 63: pitch 2.5, A = 2.5 x (circuits - 1), B = A + 4.9 (2.45 past the # end pins each side), height 7.0, depth 5.75 with the pins 2.35 from one face, tails 3.4, posts 0.64 square. PITCH, END, HEIGHT, DEPTH, FROM_FACE, TAIL, POST = 2.5, 2.45, 7.0, 5.75, 2.35, 3.4, 0.64 WALL = 0.8 # the shroud's wall, the floor and how far the posts stand in it are proportions, for looks FLOOR = 1.5 if not 2 <= circuits <= 20 or circuits in (17, 18, 19): raise ValueError("The B..B-XH-A top entry header has 2 to 16 or 20 circuits.") A = PITCH * (circuits - 1) x0, y0 = -END, -FROM_FACE model = Model() with model.sketch("housing_sketch", on="XY", name="Housing") as sk: sk.rect("housing_rect", (x0, y0), (A + END, y0 + DEPTH)) model.extrude("housing", "housing_sketch", distance=HEIGHT, name="Housing") if detail == "full": model.plane("top_plane", on="XY", offset=HEIGHT, name="Top") with model.sketch("opening_sketch", on="top_plane", name="Opening") as sk: sk.rect("opening_rect", (x0 + WALL, y0 + WALL), (A + END - WALL, y0 + DEPTH - WALL)) model.extrude("opening", "opening_sketch", distance=-(HEIGHT - FLOOR), op="cut", name="Opening") model.plane("tail_plane", on="XY", offset=-TAIL, name="Tails") with model.sketch("posts_sketch", on="tail_plane", name="Posts") as sk: for i in range(circuits): sk.rect(f"post_{i}", (i * PITCH - POST / 2, -POST / 2), (i * PITCH + POST / 2, POST / 2)) model.extrude("posts", "posts_sketch", distance=TAIL + HEIGHT - 1.0, name="Posts") model.material("pa6", color="#f1ede4") result = model.result()