main
John Lauer Component record for cre2512-fz-r001e-3: files batch 1 ff9a35c 2d ago
"""Datasheet-built STEP for Bourns CRE2512-R001..R004 (metal strip current sense chip resistor).

All printed dimensions from the Bourns CRE2512 datasheet (REV. 06/25) p.2 'Product Dimensions',
row CRE2512-R001 ~ R004: A 6.40 +/-0.20, B 3.2 +/-0.20, C 2.00 +/-0.20, T 0.90 +/-0.20 (mm).
Undimensioned (display choices, recorded in provenance): overcoat thickness 0.15 mm top and bottom,
the Mn/Cu plate filling the rest of the middle section, the marking glyph height 0.75 mm.
Construction (p.1): Mn/Cu metal alloy plate, Ni/Sn plated terminations, overcoat between them.
Frame: Z-up, mm, seated on z = 0, centred on the footprint origin, long axis on X.

usage: make_step.py out_plain.step out_marked.step
"""
import sys
import cadquery as cq

A, B, C, T = 6.40, 3.20, 2.00, 0.90
OC = 0.15          # overcoat thickness (not printed)
MARK = "R001"      # datasheet p.1 'Typical Part Marking' for CRE2512-R001
TIN = cq.Color(0.80, 0.80, 0.78)
COAT = cq.Color(0.07, 0.07, 0.07)
PLATE = cq.Color(0.72, 0.47, 0.32)
INK = cq.Color(0.92, 0.92, 0.90)
FONT = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"

def box(x0, x1, y0, y1, z0, z1):
    return cq.Workplane("XY").box(x1 - x0, y1 - y0, z1 - z0, centered=False).translate((x0, y0, z0))

def model(marked):
    a = cq.Assembly(name="CRE2512-FZ-R001E-3")
    gap = A / 2 - C
    a.add(box(-A / 2, -gap, -B / 2, B / 2, 0, T), name="terminal_1", color=TIN)
    a.add(box(gap, A / 2, -B / 2, B / 2, 0, T), name="terminal_2", color=TIN)
    a.add(box(-gap, gap, -B / 2, B / 2, OC, T - OC), name="metal_alloy_plate", color=PLATE)
    a.add(box(-gap, gap, -B / 2, B / 2, T - OC, T), name="overcoat_top", color=COAT)
    a.add(box(-gap, gap, -B / 2, B / 2, 0, OC), name="overcoat_bottom", color=COAT)
    if marked:
        # reads along the short axis (Y), as drawn in the datasheet's marking figure
        txt = (cq.Workplane("XY").text(MARK, 0.75, 0.005, font="DejaVu Sans", fontPath=FONT, kind="bold",
                                       halign="center", valign="center")
               .rotate((0, 0, 0), (0, 0, 1), 90).translate((0, 0, T + 0.005)))
        a.add(cq.Workplane("XY").add(txt.combine().val()), name="Adom.Marking.R001", color=INK)
    return a

model(False).save(sys.argv[1], exportType="STEP")
model(True).save(sys.argv[2], exportType="STEP")
print("ok")