by adom
0402 Thick Film Resistor · 2.2 kΩ ±1% · 1/16 W
master
John Lauer
MPN laser etch: etched STEP is the default, plain kept as -unetched.step; hero GLB with footprint and silkscreen; hero…
551f987
20d ago
#!/usr/bin/env python3
"""Compose after-hero.png for a slug: HTML (Ray's layout) + three.js render of the etched part (work/base.glb minus nothing: base is the posed etched STEP, no footprint art)."""
import json, sys, os, subprocess
sys.path.insert(0, os.path.dirname(__file__)); from config import C
HP = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
slug = sys.argv[1]; c = C[slug]; extra = json.loads(sys.argv[2]) if len(sys.argv) > 2 else {}
DIRS = {'tps54202ddcr': [-1.3, 0.8, 1.15], 'eee-fk1v470p': [1.3, 0.55, 1.25]}
mark = 'vendor marking' if c['mark'] is None else 'virtual MPN mark'
cfg = dict(glb=f'/{slug}/work/base.glb', dir=DIRS.get(slug, [-0.9, -1.3, 1.1]), dist=7.6,
title=c['big'], mpn=c['mpn'] if c.get('basic') else '', cat=c['spec'], mfr=f"{c['mfr']} • {c['pkg']}",
pill='ADOM BASIC PART' if c.get('basic') else '', foot=f"Manufacturer datasheet · {c['cad']} · {mark} · Adom Wiki")
cfg.update(extra)
html = open(os.path.join(HP, '_tools/hero_template.html')).read().replace('__CFG__', json.dumps(cfg, ensure_ascii=False))
open(f'{HP}/{slug}/work/hero.html', 'w').write(html)
r = subprocess.run(['node', f'{HP}/_tools/shoot_hero.js', f'http://127.0.0.1:8941/{slug}/work/hero.html', f'{HP}/{slug}/after-hero.png'], capture_output=True, text=True)
print(slug, r.returncode, r.stdout[-500:], r.stderr[-500:])