R2:底板 / 刀片布局布线脚本、快照、截图与规划文档更新(含外壳、打印件、布线归档)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
这个提交包含在:
zhou yang
2026-10-04 19:24:45 +08:00
共同撰写人 Claude Opus 5.5
父节点 cd01640c40
当前提交 cf7cc9cf90
共修改 759 个文件,包含 76962 行新增和 5299 行删除
+81
查看文件
@@ -0,0 +1,81 @@
# -*- coding: utf-8 -*-
u"""把 R900~R909(U32 十个 strap 脚的 100k 下拉)摆到载板上 —— **只动这十颗**。
/c/Python314/python .claude/pcb2_straps.py # 干跑
/c/Python314/python .claude/pcb2_straps.py --push # 下发 + 回读核对
坐标取自 `pcb2_place.POS`(已经把这十颗加进计划表了,整板 `--push` 才不会把它们丢掉)。
不用 `pcb2_place.py --push` 是因为那会把 228 个件全部 `modify(layer)` + `modify(x,y,rot)`
过一遍 —— 载板已经布完线铺完铜,没必要为了十颗新件把所有件都动一次。
"""
import json
import os
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
from eda import run
import pcb2_place as PL
POS = PL.plan()
PCB = '942ed1560d81c1e7'
MIL = 39.3700787401575
NEW = ['R900', 'R901', 'R902', 'R903', 'R904', 'R905', 'R906', 'R907', 'R908', 'R909']
def call(js, timeout=240):
r = run(js, timeout=timeout)
if not r.get('success'):
raise RuntimeError(json.dumps(r, ensure_ascii=False)[:900])
return r['result']
def main():
push = '--push' in sys.argv
plan = [[d, round(POS[d][0] * MIL, 3), round(POS[d][1] * MIL, 3), POS[d][2]] for d in NEW]
for d, x, y, r in plan:
print(u' %-5s (%9.3f, %9.3f) mil = (%6.2f, %5.2f) mm rot %d 底层'
% (d, x, y, x / MIL, y / MIL, r))
if not push:
print(u'加 --push 执行')
return
call("""
await eda.dmt_EditorControl.openDocument('%s'); await new Promise(r=>setTimeout(r,2200));
return 1;""" % PCB)
n = call("""
const P = %s;
const map = {};
for (const c of await eda.pcb_PrimitiveComponent.getAll()) map[c.getState_Designator()] = c;
let n = 0;
for (const [d, x, y, rot] of P) {
const c = map[d]; if (!c) throw new Error('板上没有 ' + d);
await eda.pcb_PrimitiveComponent.modify(c.getState_PrimitiveId(), {layer: 2});
await eda.pcb_PrimitiveComponent.modify(c.getState_PrimitiveId(), {x, y, rotation: rot});
n++;
}
return n;""" % json.dumps(plan))
print(u'已摆 %d 颗' % n)
got = call("""
const P = %s;
const map = {};
for (const c of await eda.pcb_PrimitiveComponent.getAll()) map[c.getState_Designator()] = c;
const out = [];
for (const [d] of P) { const c = map[d];
out.push([d, Math.round(c.getState_X()*1000)/1000, Math.round(c.getState_Y()*1000)/1000,
c.getState_Rotation(), c.getState_Layer()]); }
await eda.pcb_Document.save();
return out;""" % json.dumps(plan))
bad = []
for (d, x, y, r), (gd, gx, gy, gr, gl) in zip(plan, got):
if abs(gx - x) > 0.02 or abs(gy - y) > 0.02 or gr != r or gl != 2:
bad.append(u'%s 期望 (%.2f,%.2f) rot%d L2,实测 (%.2f,%.2f) rot%s L%s'
% (d, x, y, r, gx, gy, gr, gl))
if bad:
raise SystemExit(u'回读对不上:\n ' + u'\n '.join(bad))
print(u'回读 %d 颗,位置/角度/层逐个一致;已存盘' % len(got))
main()