main
John Lauer Component files 1/1 aef1077 3d ago
"""AI-created simplified model of Hirose FH12-22S-0.5SH(55), built from the Hirose
drawing EDC3-150229-11 (sheet 1 + dimension table sheet 5, 22-pos row).

Frame: Adom/KiCad model frame, Z up, seating plane z=0, origin = centre of the
housing+actuator outline (5.6 deep x B=14.1 wide). +Y (model) = rear (contact tails),
-Y (model) = front (FFC insertion / actuator). Pin 1 at x = -5.25 (KiCad top view, tails up).
"""
import sys
import cadquery as cq

N = 22
P = 0.5
A = 10.5    # contact span (table)
B = 14.1    # housing width (table)
C = 11.57   # FFC opening (table)
D = 15.1    # overall width incl. fitting nails (table)
E = 12.9    # actuator width (table)
DEPTH = 5.6     # housing + actuator, sheet 1 side view 5.6 +-0.3
HDEPTH = 4.6    # housing, side view 4.6 +-0.2
H_HOUSING = 1.85
H_TOTAL = 2.0
TAIL = 0.8      # contact tails beyond housing rear, 0.8 +-0.2

y_front = -DEPTH / 2          # -2.8
y_rear = DEPTH / 2            # +2.8

housing = (cq.Workplane("XY")
           .box(B, HDEPTH, H_HOUSING, centered=(True, False, False))
           .translate((0, y_rear - HDEPTH, 0)))
# FFC entry slot (0.35 tall, C wide, 3.4 deep from housing front), reference (3.4) in detail a
slot = (cq.Workplane("XY").box(C, 3.4, 0.35, centered=(True, False, False))
        .translate((0, y_rear - HDEPTH, 0.55)))
housing = housing.cut(slot)

# actuator: front lip 1.0 deep full height + cover plate over the front half of the housing
act_lip = (cq.Workplane("XY").box(E, DEPTH - HDEPTH, H_TOTAL, centered=(True, False, False))
           .translate((0, y_front, 0)))
act_top = (cq.Workplane("XY").box(E, 2.4, H_TOTAL - H_HOUSING, centered=(True, False, False))
           .translate((0, y_front + 1.0, H_HOUSING)))
actuator = act_lip.union(act_top)
# polarization mark (drawing: triangle at the pin-1 end of the front edge) as a small recess
mark = (cq.Workplane("XY").polyline([(-5.6, -2.55), (-5.0, -2.55), (-5.3, -2.05)]).close()
        .extrude(0.05).translate((0, 0, H_TOTAL - 0.05)))
actuator = actuator.cut(mark)

# fitting nails (metal), centred on the PCB mounting pads at KiCad y = -0.2 -> model y = +0.2
nails = None
for sx in (-1, 1):
    plate = (cq.Workplane("XY").box((D - B) / 2, 2.0, 1.2, centered=(False, True, False))
             .translate((B / 2 if sx > 0 else -D / 2, 0.2, 0)))
    foot = (cq.Workplane("XY").box(1.0, 2.0, 0.1, centered=(False, True, False))
            .translate((B / 2 - 0.5 if sx > 0 else -B / 2 - 0.5, 0.2, 0)))
    n = plate.union(foot)
    nails = n if nails is None else nails.union(n)

# contacts: 0.2 wide tails, 0.15 thick, from housing rear to 0.8 beyond, plus a riser into the body
contacts = None
for i in range(N):
    x = -A / 2 + i * P
    tail = (cq.Workplane("XY").box(0.2, TAIL + 0.4, 0.15, centered=(True, False, False))
            .translate((x, y_rear - 0.4, 0)))
    contacts = tail if contacts is None else contacts.union(tail)

asm = cq.Assembly(name="FH12-22S-0.5SH(55)")
asm.add(housing, name="housing", color=cq.Color(0.82, 0.74, 0.58))
asm.add(actuator, name="actuator", color=cq.Color(0.22, 0.13, 0.08))
asm.add(nails, name="fitting_nails", color=cq.Color(0.78, 0.78, 0.80))
asm.add(contacts, name="contacts", color=cq.Color(0.85, 0.68, 0.25))
asm.export(sys.argv[1])
print("OK", sys.argv[1])