main
John Lauer Add symbol, footprint, Fusion and Altium libraries, viewers, provenance, README ab389b2 8h ago
#!/usr/bin/env python3
"""Signal-lead row (+x side) of the DVG0010A model: foot section at x = tip - 0.15 -> lead widths, centres, pitch;
gauge-plane L on pin 10's centre line (y = +4.445). usage: dims_signal.py part.step"""
import sys, json, cadquery as cq
from OCP.BRepAlgoAPI import BRepAlgoAPI_Section
from OCP.gp import gp_Pln, gp_Pnt, gp_Dir
def sec(shape, p, d):
    s = BRepAlgoAPI_Section(shape.wrapped, gp_Pln(gp_Pnt(*p), gp_Dir(*d))); s.Build(); return cq.Shape.cast(s.Shape())
a = cq.importers.importStep(sys.argv[1]); shp = cq.Compound.makeCompound(a.solids().vals()); r = lambda v: round(v, 4)
prof = sec(shp, (0, 4.445, 0), (0, 1, 0)); pb = prof.BoundingBox()
xs = sorted((v.X for v in sec(prof, (0, 0, 0.25), (0, 0, 1)).Vertices() if v.X > 0 and pb.xmax - v.X > 1e-3), reverse=True)
foot = sec(shp, (pb.xmax - 0.15, 0, 0), (1, 0, 0)); ys = sorted(set(r(v.Y) for v in foot.Vertices())); gr = [ys[i:i + 2] for i in range(0, len(ys), 2)]
c = [(g[0] + g[-1]) / 2 for g in gr]
print(json.dumps({"row": "+x (pins 3..10)", "L_gauge_pin10": r(pb.xmax - xs[0]) if xs else None, "b_lead_width": [r(g[-1] - g[0]) for g in gr],
                  "centres_y": [r(v) for v in c], "pitch": [r(c[i + 1] - c[i]) for i in range(len(c) - 1)]}, indent=1))