# -*- coding: utf-8 -*- u"""截底板 PCB 的当前渲染:python .claude/r2/shot_base.py `.claude/shot.py` 是原理图版(读 dmt_Schematic 的页名),PCB 页上会抛错,所以另起这一份。 """ import base64 import json import os import sys HERE = os.path.dirname(os.path.abspath(__file__)) sys.path.insert(0, os.path.dirname(HERE)) sys.path.insert(0, HERE) from eda import run # noqa: E402 import pcb_base as B # noqa: E402 out = sys.argv[1] js = """ const sleep = ms => new Promise(r => setTimeout(r, ms)); await eda.dmt_EditorControl.openDocument('%s'); await sleep(1500); await eda.dmt_EditorControl.zoomToAllPrimitives(); await sleep(1500); const img = await eda.dmt_EditorControl.getCurrentRenderedAreaImage(); const bytes = new Uint8Array(await new Response(img).arrayBuffer()); let s=''; for (let i=0;i', out)