main
John Lauer Publish 0.1.0 c682996
#!/usr/bin/env python3
"""AI-created 3D model for Dialight 587-1024-147F (2020 addressable RGB LED).

NO manufacturer CAD exists for this part (checked Mouser/SnapEDA-class sources).
Geometry is modeled from the datasheet (rev Jan 2024 / 0225):
  - p.1 mechanical drawing: body 2.0 x 2.0 x 0.9 mm (LxWxH), clear epoxy lens
  - p.1 BOTTOM VIEW: 4 terminals 0.6 x 0.6 mm, 0.8 mm gap (1.4 mm pitch, centers +/-0.7 mm)
Orientation: Z-up, seating plane (terminal bottoms) on z=0.
Pin 1 (DOUT) terminal at (-x, -y) so the model aligns unrotated with the
KiCad footprint Dialight_587-1024-147F (pin 1 top-left, IPC-7351 zero orientation).
Units: mm.
"""
import cadquery as cq

BODY_XY = 2.0          # p.1: 2.0 x 2.0 mm
BODY_TOP = 0.9         # p.1 side view: total height 0.9 mm
TERM_H = 0.08          # terminal standoff (modeling choice; datasheet gives none)
TERM_X = 0.6           # p.1 bottom view: 0.6 mm wide (measured square)
TERM_Y = 0.6           # p.1 bottom view: square terminals (0.8 mm is the GAP, not the height)
TERM_PITCH = 1.4       # p.1 bottom view: 0.6 mm terminal + 0.8 mm gap = 1.4 mm pitch
CHAMFER = 0.12         # top-edge bevel (modeling choice, matches datasheet photo)

half = BODY_XY / 2.0
off = TERM_PITCH / 2.0

body = (
    cq.Workplane("XY", origin=(0, 0, TERM_H))
    .box(BODY_XY, BODY_XY, BODY_TOP - TERM_H, centered=(True, True, False))
    .edges(">Z")
    .chamfer(CHAMFER)
)

terminals = None
for sx in (-1, 1):
    for sy in (-1, 1):
        t = cq.Workplane("XY", origin=(sx * off, sy * off, 0)).box(
            TERM_X, TERM_Y, TERM_H + 0.02, centered=(True, True, False)
        )
        terminals = t if terminals is None else terminals.union(t)

part = body.union(terminals)

assy = cq.Assembly()
# clear-epoxy lens look: light neutral gray; terminals: tinned-metal gray
assy.add(body, name="587-1024-147F-body", color=cq.Color(0.82, 0.84, 0.88, 0.9))
assy.add(terminals, name="587-1024-147F-terminals", color=cq.Color(0.70, 0.71, 0.74))

out = "/home/adom/project/adom-led-grid/parts/dialight-587-1024-147f/page/587-1024-147f.step"
assy.save(out)
print("wrote", out)

bb = part.val().BoundingBox()
print("bbox x", round(bb.xlen, 4), "y", round(bb.ylen, 4), "z", round(bb.zlen, 4),
      "zmin", round(bb.zmin, 4))