# -*- coding: utf-8 -*- """Push selected references from the current base-board placement plan.""" import json import sys import place_base as P if __name__ == '__main__': refs = sys.argv[1:] pos = P.plan()[0] missing = [ref for ref in refs if ref not in pos] if missing: raise SystemExit('unknown references: ' + ' '.join(missing)) selected = {ref: pos[ref] for ref in refs} P.push(selected) got = P.call("const want=%s,o={}; for(const c of await eda.pcb_PrimitiveComponent.getAll())" " if(want.includes(c.designator)) o[c.designator]=[c.x/%s,c.y/%s,c.rotation||0];" " return o;" % (json.dumps(refs), P.MIL, P.MIL)) bad = [] for ref, (x, y, rot) in selected.items(): if ref not in got or abs(got[ref][0] - x) > 0.02 or abs(got[ref][1] - y) > 0.02 \ or int(round(got[ref][2])) % 360 != rot % 360: bad.append(ref) if bad: raise SystemExit('readback mismatch: ' + ' '.join(bad)) print('readback OK: ' + ' '.join(refs))