main
Colby Knox 1.1.4: clean AMPLH5030S model. The vendor print was 132 faces 1 um under and on the top face (z-fighting, a torn top in… bc3b0df
#!/usr/bin/env python3
"""Clean AMPLH5030S series model (Abracon molded shielded inductor), Z-up, seated on Z = 0, pad 1 at -X.

The vendor STEP drew the marking as 132 faces 1 um under and on the body's top face (z-fighting in every
renderer) and its two terminals as solid blocks driven 1.2 mm into the body. This one has no coincident or
interpenetrating geometry: the body, two L-shaped tin electrodes that only touch it, and the ink marking
raised 0.02 mm above the top. Dimensions follow the vendor model and the datasheet drawing:
body 5.4 x 5.2 x 2.75 mm on a 0.05 mm stand-off, terminals 3.0 mm wide wrapping 1.2 mm under each end.
"""
import cadquery as cq

BX, BY, Z0, Z1 = 2.70, 2.60, 0.05, 2.80     # body half-extents and z range
TW, TL, TH, T = 1.50, 1.20, 1.05, 0.05      # terminal half-width, bottom length, end height, plating thickness

body = (cq.Workplane("XY").box(2 * BX, 2 * BY, Z1 - Z0, centered=(True, True, False)).translate((0, 0, Z0))
        .edges("|Z").fillet(0.25).edges(">Z").fillet(0.12))


def terminal(sign):
    # bottom plate under the body (z 0..0.05) plus the end plate on the outside of the end face
    bottom = cq.Workplane("XY").box(TL, 2 * TW, T, centered=(False, True, False)).translate((BX - TL, 0, 0))
    end = cq.Workplane("XY").box(T, 2 * TW, TH, centered=(False, True, False)).translate((BX, 0, 0))
    t = bottom.union(end)
    return t if sign > 0 else t.mirror("YZ")


# ink marking, raised 0.02 mm, one line along X (between the terminals), centred, the size and direction of Abracon's model
mark = (cq.Workplane("XY").workplane(offset=Z1)
        .text("AMPLH5030S", 0.42, 0.02, halign="center", valign="center", combine=False))

asm = cq.Assembly(name="AMPLH5030S-150MT")
asm.add(body, name="body", color=cq.Color(0.22, 0.22, 0.22))
asm.add(terminal(-1), name="terminal_1", color=cq.Color(0.80, 0.80, 0.82))
asm.add(terminal(+1), name="terminal_2", color=cq.Color(0.80, 0.80, 0.82))
asm.add(mark, name="marking", color=cq.Color(0.78, 0.78, 0.76))
asm.save("AMPLH5030S-150MT.step")
bb = asm.toCompound().BoundingBox()
print(f"x {bb.xmin:.3f}..{bb.xmax:.3f}  y {bb.ymin:.3f}..{bb.ymax:.3f}  z {bb.zmin:.3f}..{bb.zmax:.3f}")