"""JST PH shrouded header, 2.0 mm pitch, top entry, through-hole: B2B-PH-K to B16B-PH-K. 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 PH connector catalogue, Through-hole type Header, Top entry type, p. 2: pitch 2.0, A = 2.0 x (circuits - 1), B = A + 3.9 (1.95 past the end pins # each side), height 6, depth 4.5 with the pins 1.7 from one face, tails 3.4, posts 0.5 square. PITCH, END, HEIGHT, DEPTH, FROM_FACE, TAIL, POST = 2.0, 1.95, 6.0, 4.5, 1.7, 3.4, 0.5 WALL = 0.6 # the shroud's wall, the floor and how far the posts stand in it are proportions, for looks FLOOR = 1.2 if not 2 <= circuits <= 16: raise ValueError("The B..B-PH-K top entry header has 2 to 16 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()