component
2-1445098-3
Public Made by Adomby adom
TE Connectivity Micro MATE-N-LOK header, right angle, 3 position, 3.00 mm pitch, plastic holddown. Footprint and 3D built from the TE drawing.
main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
#!/usr/bin/env python3
"""Evidence overlays for 2-1445098-3: the built STEP projected orthographically at the drawing's own scale (4:1 on the
A2 sheet: 47.24 px/mm at 300 dpi, 23.62 px/mm at 150 dpi), drawn in translucent red over TE customer drawing
C-1445098 rev C; and the footprint's holes over the sheet 2 '3 position' PCB layout.
usage: overlay_2_1445098_3.py <step> <kicad_mod> <drawing.pdf> <outdir>"""
import os, re, subprocess, sys
import numpy as np
import cadquery as cq
from PIL import Image, ImageDraw
step, kmod, pdf, out = sys.argv[1:5]
os.makedirs(out, exist_ok=True)
tris = []
for sol in cq.importers.importStep(step).solids().vals():
vs, fs = sol.tessellate(0.01, 0.2)
V = np.array([(v.x, v.y, v.z) for v in vs])
tris += [V[list(f)] for f in fs]
def page(n, dpi, x, y, w, h, name):
base = os.path.join(out, name)
subprocess.run(['pdftoppm', '-r', str(dpi), '-f', str(n), '-l', str(n), '-x', str(x), '-y', str(y), '-W', str(w),
'-H', str(h), '-png', '-singlefile', pdf, base], check=True)
im = Image.open(base + '.png').convert('RGB'); os.remove(base + '.png'); return im
def project(img, f, label, name):
ov = Image.new('RGBA', img.size, (0, 0, 0, 0)); d = ImageDraw.Draw(ov)
for t in tris:
d.polygon([f(p) for p in t], fill=(255, 0, 0, 35))
res = Image.alpha_composite(img.convert('RGBA'), ov).convert('RGB')
ImageDraw.Draw(res).text((8, 8), label, fill=(200, 0, 0))
res.save(os.path.join(out, name))
PX = 300 / 25.4 * 4 # 47.24 px/mm
# 1. sheet 1 right-side view: mating face at x = 610, seating plane (standoff bottom) at y = 505 in this crop;
# image right = -y (toward the rear), image up = +z
img = page(1, 300, 2448, 1024, 1150, 900, 's1')
project(img, lambda p: (610 + (8.92 - p[1]) * PX, 505 - p[2] * PX),
'model (red) over TE C-1445098 rev C sheet 1 side view, 47.24 px/mm (4:1 at 300 dpi)', 'overlay_sheet1_side_view.png')
# 2. sheet 2 '3 POS.' mating-face view: housing centre x = 298.5, housing top y = 75 -> seat at 75 + 4.37 * PX;
# seen from the mating face (+y), image right = -x
img = page(2, 300, 874, 1349, 680, 480, 's2')
project(img, lambda p: (298.5 - p[0] * PX, 75 + 4.37 * PX - p[2] * PX),
'model (red) over sheet 2 3 POS. mating-face view (keying), 47.24 px/mm', 'overlay_sheet2_3pos_front_view.png')
# 3. sheet 2 PCB layout for 3 position (150 dpi, 23.62 px/mm): middle contact hole at (312, 208) in this crop.
# Footprint holes (KiCad frame, mating face toward -y) drawn rotated 180 deg so the holddown is below the row,
# as the drawing shows it; the layout is symmetric about the middle contact.
img = page(2, 150, 2573, 899, 680, 520, 's3')
px = 150 / 25.4 * 4
t = open(kmod).read()
ov = Image.new('RGBA', img.size, (0, 0, 0, 0)); d = ImageDraw.Draw(ov)
for m in re.finditer(r'\(pad "([^"]*)" (\w+) \w+\s+\(at ([-\d.]+) ([-\d.]+)\)\s+\(size ([-\d.]+) [-\d.]+\)\s+\(drill ([-\d.]+)\)', t):
x, y, size, drill = (float(v) for v in m.groups()[2:])
cx, cy = 312 - x * px, 208 - y * px
r = drill / 2 * px
d.ellipse((cx - r, cy - r, cx + r, cy + r), outline=(255, 0, 0, 255), width=2)
res = Image.alpha_composite(img.convert('RGBA'), ov).convert('RGB')
ImageDraw.Draw(res).text((8, 8), 'footprint drills (red) over sheet 2 PCB layout for 3 position, 23.62 px/mm', fill=(200, 0, 0))
res.save(os.path.join(out, 'overlay_sheet2_pcb_layout.png'))
print('ok')