"""PCB barrier terminal block with M4 screws at 9.5 mm pitch, Ningbo Kangnex HB9500 (open) and HB9500M (with a cover). Pin 1 is at the origin, the row along +X, the housing on the XY plane with its long wall on the +Y side and the screw pockets open towards -Y, the solder pins down through the board. The housing, every screw, every solder pin and the cover are separate solids. Dimensions from the maker's drawings in the README.""" from steve import Model series = "HB9500" # Series: HB9500 (open) or HB9500M (with cover) positions = 2 # Positions (poles) # Ningbo Kangnex customer drawings "HB9500 series" and "HB9500M series", barrier terminal block, pitch 9.50 mm (one page each, no drawing number # or revision; files dated 2020-08-20). length: N x 9.5 + extra; pin row (N - 1) x 9.5; depth and height: the housing's section; total: height # over the cover (HB9500M); pin_l: solder pin below the housing; pin_w x pin_t: the pin along the row x across it; pin_wall: the pin's centre # line from the housing's long face it is dimensioned from ("side": the face on the long wall's side, +Y, or the open side, -Y). PITCH = 9.5 SERIES = { "HB9500": {"extra": 1.5, "depth": 17.80, "height": 14.20, "pin_l": 6.30, "pin_w": 1.50, "pin_t": 0.70, "pin_wall": 5.10, "side": "wall"}, "HB9500M": {"extra": 1.5, "depth": 16.00, "height": 13.00, "total": 16.8, "pin_l": 5.30, "pin_w": 1.50, "pin_t": 0.70, "pin_wall": 3.95, "side": "open"}, } # The sizes the catalogue lists; the drawings give the length for any N. MIN_POSITIONS = 2 MAX_POSITIONS = 12 # Proportions, for looks only (drawn, not dimensioned): the pockets' floor at FLOOR of the height, the long wall WALL thick, the screw heads # HEAD_D across and HEAD_H high in the middle of their pockets. The barriers between poles are as thick as the length's extra 1.5. FLOOR = 0.45 WALL = 1.5 HEAD_D = 7.0 HEAD_H = 2.5 if series not in SERIES: raise ValueError(f"no series {series!r}: {', '.join(SERIES)}") if not MIN_POSITIONS <= positions <= MAX_POSITIONS: raise ValueError(f"positions is {MIN_POSITIONS} to {MAX_POSITIONS}") B = SERIES[series] length = positions * PITCH + B["extra"] x0 = -(length - (positions - 1) * PITCH) / 2 # the pin row is in the middle of the length, as drawn back = B["pin_wall"] if B["side"] == "wall" else B["depth"] - B["pin_wall"] front = back - B["depth"] H = B["height"] floor = FLOOR * H barrier = B["extra"] model = Model() with model.sketch("housing_sketch", on="XY", name="Housing") as sk: sk.rect("housing_rect", (x0, front), (x0 + length, back)) model.extrude("housing", "housing_sketch", distance=H, op="new", body="housing_body", name="Housing") model.plane("floor_plane", on="XY", offset=floor, name="Pocket floor") with model.sketch("pockets_sketch", on="floor_plane", name="Screw pockets") as sk: for i in range(positions): sk.rect(f"pocket_{i + 1}", (i * PITCH - PITCH / 2 + barrier / 2, front - 1), (i * PITCH + PITCH / 2 - barrier / 2, back - WALL)) model.extrude("pockets", "pockets_sketch", distance=H - floor + 1, op="cut", name="Screw pockets") screws, pins = [], [] y_screw = (front + back - WALL) / 2 for i in range(positions): with model.sketch(f"screw_{i + 1}_sketch", on="floor_plane", name=f"Screw {i + 1}") as sk: sk.circle(f"screw_{i + 1}_circle", (i * PITCH, y_screw), HEAD_D / 2) model.extrude(f"screw_{i + 1}", f"screw_{i + 1}_sketch", distance=HEAD_H, op="new", body=f"screw_{i + 1}_body", name=f"Screw {i + 1}") screws.append(f"screw_{i + 1}_body") # Each solder pin is its own solid, from its end below the board up to the housing's bottom face. model.plane("pin_plane", on="XY", offset=-B["pin_l"], name="Solder pins") for i in range(positions): with model.sketch(f"pin_{i + 1}_sketch", on="pin_plane", name=f"Pin {i + 1}") as sk: sk.rect(f"pin_{i + 1}_rect", (i * PITCH - B["pin_w"] / 2, -B["pin_t"] / 2), (i * PITCH + B["pin_w"] / 2, B["pin_t"] / 2)) model.extrude(f"pin_{i + 1}", f"pin_{i + 1}_sketch", distance=B["pin_l"], op="new", body=f"pin_{i + 1}_body", name=f"Pin {i + 1}") pins.append(f"pin_{i + 1}_body") if "total" in B: # The cover: a plain plate over the housing, from the housing's top to the sheet's height over the cover. model.plane("cover_plane", on="XY", offset=H, name="Cover") with model.sketch("cover_sketch", on="cover_plane", name="Cover") as sk: sk.rect("cover_rect", (x0, front), (x0 + length, back)) model.extrude("cover", "cover_sketch", distance=B["total"] - H, op="new", body="cover_body", name="Cover") # The drawings' material list: plastic PA66, UL94V-0 (pa6 is the nearest in the materials list); solder pins brass, tin plated; screws M4.0, # steel, nickel plated. The cover's material is not named, so none is set. model.material("pa6", bodies=["housing_body"], color="#2b2d30") model.material("brass", bodies=pins, color="#c9ccd1") model.material("steel-generic", bodies=screws, color="#b9bcc0") result = model.result()