# -*- coding: utf-8 -*- u"""截 PCB 指定区域:python .claude/shot_pcb_region.py [pcbUuid] ⚠️ zoomToRegion 的参数顺序是 (left, right, top, bottom),不是 (x0,y0,x1,y1);传错不报错只是不缩放。""" import base64, io, os, sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from eda import run MIL = 39.3701 out = sys.argv[1] x0, y0, x1, y1 = [float(v) * MIL for v in sys.argv[2:6]] uuid = sys.argv[6] if len(sys.argv) > 6 else '7e9415a16a909c51' JS = u""" const sleep=ms=>new Promise(r=>setTimeout(r,ms)); await eda.dmt_EditorControl.openDocument('%s'); await sleep(1800); await eda.dmt_EditorControl.zoomToRegion(%f, %f, %f, %f); await sleep(1800); const img = await eda.dmt_EditorControl.getCurrentRenderedAreaImage(); const bytes = new Uint8Array(await new Response(img).arrayBuffer()); let s=''; for (let i=0;i