component
0705530003
Public Made by Adomby adom
Molex SL header with latch, right angle, 1x4, 2.54 mm, 70553-0003. Footprint from the Molex drawing; 3D is Molex's own model.
main
"""Draw a footprint's drills (red) and pads (orange outline) over a drawing's recommended PCB layout.
usage: fpoverlay.py <kicad_mod> <img> <out> <s px/mm> <ox> <oy> <ux,uy> <vx,vy> <crop l,t,r,b px>
pixel = (ox, oy) + x_fp*(ux,uy)*s + y_fp*(vx,vy)*s (u, v = unit image directions of footprint +X and +Y)"""
import re, sys
from PIL import Image, ImageDraw
kmod, img, out = sys.argv[1:4]
s, ox, oy = map(float, sys.argv[4:7])
ux, uy = map(float, sys.argv[7].split(',')); vx, vy = map(float, sys.argv[8].split(','))
l, t, r, b = map(int, sys.argv[9].split(','))
txt = open(kmod).read()
pads = [(float(x), float(y), float(sz), float(d)) for x, y, sz, d in re.findall(
r'\(pad "[^"]*" \w+ \w+\s*\(at ([-\d.]+) ([-\d.]+)\)\s*\(size ([-\d.]+) [-\d.]+\)\s*\(drill ([-\d.]+)\)', txt)]
im = Image.open(img).convert('RGB').crop((l, t, r, b)); up = 2
im = im.resize((im.width * up, im.height * up), Image.LANCZOS); dr = ImageDraw.Draw(im)
for x, y, sz, d in pads:
px = (ox + (x * ux + y * vx) * s - l) * up; py = (oy + (x * uy + y * vy) * s - t) * up
for rad, col, w in ((d / 2, (230, 0, 0), 3), (sz / 2, (255, 140, 0), 2)):
R = rad * s * up; dr.ellipse([px - R, py - R, px + R, py + R], outline=col, width=w)
im.save(out); print(out, len(pads), 'holes')