by adom
0805 MLCC · 1 µF ±10% X7R · 50 V
master
John Lauer
Laser mark by the planner (adom-aiflow 0.1.49): re-etched, outlines regenerated, GLB / hero / outline symbol rebuilt; l…
cac1d53
17d ago
"""Use the manufacturer's own STEP as the page model: copy it, stand it up Z-up (Samsung exports Y-up, seated on
y = 0: +90 deg about X through the origin, XCAF so colours and names stay), and record where it came from.
Called by mark_pass.py's MODEL_BUILDER hook: build_vendor_step.py OUT.step REPORT.json --name MPN
env: VENDOR_STEP (path), VENDOR_SOURCE (text: where it was downloaded), VENDOR_NOTE (optional)."""
import hashlib, json, os, subprocess, sys
out, rp = sys.argv[1:3]
NAME = sys.argv[sys.argv.index("--name") + 1] if "--name" in sys.argv else ""
src = os.environ["VENDOR_STEP"]
ROT = "/home/adom/project/aiflow-work/merged/tools/laser-etch/rotate_step_xcaf.py"
sys.path.insert(0, "/home/adom/project/basic-parts-overhaul"); import bpo_art
b = bpo_art.step_bbox(src)
yup = abs(b[1]) < 0.02 and abs(b[2] + b[5]) < 0.02
if yup:
subprocess.run([sys.executable, ROT, src, out, "90", "x", "0,0,0"], check=True, capture_output=True)
else:
open(out, "wb").write(open(src, "rb").read())
a = bpo_art.step_bbox(out)
head = open(src, encoding="latin-1").read(3000); fn = head[head.find("FILE_NAME (") + 11:].split(",")[0].strip(" ('")
sha = lambda p: hashlib.sha256(open(p, "rb").read()).hexdigest()
raw = os.path.join(os.path.dirname(os.path.abspath(rp)), "%s-samsung-%s" % (NAME, fn if fn.lower().endswith((".step", ".stp")) else fn + ".step"))
open(raw, "wb").write(open(src, "rb").read()) # the manufacturer's file, byte for byte
json.dump(dict(tool="build_vendor_step.py", mpn=NAME, kind="manufacturer STEP", file_name_in_step=fn, source=os.environ.get("VENDOR_SOURCE"),
note=os.environ.get("VENDOR_NOTE"), source_sha256=sha(src), raw_copy=os.path.basename(raw), stood_up=yup,
transform="rotate +90 deg about X through the origin (XCAF, colours and names kept)" if yup else None,
bbox_before_mm=[round(v, 4) for v in b], bbox_after_mm=[round(v, 4) for v in a]), open(rp, "w"), indent=1)
print(json.dumps(dict(out=out, stood_up=yup, height_mm=round(a[5] - a[2], 4))))