- 规则:铜层 2→4,差分 0.28/0.18,间距 0.15,过孔 0.3/0.2(rules_base) - 几何:98×98 板框 + 4×M3,槽阵居中,L1 12V 大铜 + 指头(pcb_base) - 摆位:五插槽留 L1,其余 133 件翻到 L4;背面镜像规则实测;Hub 放走廊 2、 东移 2.5 mm;扇出圈 / 小件间距 1.5(去耦例外)/ 9 A 过孔阵禁区(place_base) - 叠层按用户决定改为 L1 槽面 / L2 整层 +3V3 / L3 整层 GND / L4 器件面 - 布线:D± 七对按构造布通(USB3 掉头、USB1/2 北去掉头、USB4/5 东绕、 J23 桥),+3V3 / GND / +12V 平面网每脚一孔,0.125 网格 + PathFinder 开关(route_base、remote_route.ps1);剩 37 个网待手工补 - 铺铜:4 层重写,入口链自南向北切段 + 断面校核(pour_base); 已下发布线 / 缝合孔 / 铜面轮廓,填铜未成功(待查) - 工具:plot_base / plot_routes / shot_base,board_check 通孔两层都算 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_0168Bu6SEx3cXXCJLkdnE6zB
53 行
2.7 KiB
Python
53 行
2.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
u"""把载板 PCB2 当前的全部铜/元件状态落成一个 JSON(可回滚的安全网)。
|
|
|
|
/c/Python314/python .claude/pcb2_snapshot.py <out.json>
|
|
|
|
抓:元件 (位号,x,y,rot,layer)、导线、过孔、铺铜(含多边形)、自由焊盘、layer 11 多段线、填充。
|
|
单位 mil(EasyEDA 原生),不换算。
|
|
"""
|
|
import io, json, os, sys
|
|
HERE = os.path.dirname(os.path.abspath(__file__))
|
|
sys.path.insert(0, HERE)
|
|
from eda import run
|
|
|
|
PCB = '942ed1560d81c1e7'
|
|
JS = u"""
|
|
await eda.dmt_EditorControl.openDocument('%s');
|
|
await new Promise(r=>setTimeout(r,1500));
|
|
const out = {comps:[], lines:[], vias:[], pours:[], fills:[], pads:[], polys:[], arcs:[]};
|
|
for (const c of await eda.pcb_PrimitiveComponent.getAll())
|
|
out.comps.push([c.getState_Designator(), c.getState_X(), c.getState_Y(), c.getState_Rotation(), c.getState_Layer()]);
|
|
for (const l of await eda.pcb_PrimitiveLine.getAll())
|
|
out.lines.push([l.layer, l.startX, l.startY, l.endX, l.endY, l.lineWidth, l.net]);
|
|
for (const a of await eda.pcb_PrimitiveArc.getAll())
|
|
out.arcs.push([a.layer, a.net, JSON.stringify(a).slice(0, 400)]);
|
|
for (const v of await eda.pcb_PrimitiveVia.getAll())
|
|
out.vias.push([v.x, v.y, v.holeDiameter, v.diameter, v.net]);
|
|
for (const p of await eda.pcb_PrimitivePour.getAll()) {
|
|
let poly = null; try { poly = p.complexPolygon; } catch(e) {}
|
|
out.pours.push({layer: p.layer, net: p.net, name: p.pourName, prio: p.pourPriority, fill: p.pourFillMethod,
|
|
poly: poly ? JSON.parse(JSON.stringify(poly)) : null});
|
|
}
|
|
for (const f of await eda.pcb_PrimitiveFill.getAll())
|
|
out.fills.push({layer: f.layer, net: f.net, raw: JSON.parse(JSON.stringify(f)).complexPolygon || null});
|
|
for (const p of await eda.pcb_PrimitivePad.getAll()) {
|
|
const pid = p.getState_PrimitiveId();
|
|
out.pads.push([pid, p.getState_PadNumber(), p.getState_Layer(), p.getState_X(), p.getState_Y(), p.getState_Net()]);
|
|
}
|
|
for (const p of await eda.pcb_PrimitivePolyline.getAll())
|
|
out.polys.push({layer: p.layer, raw: JSON.parse(JSON.stringify(p))});
|
|
return out;
|
|
""" % PCB
|
|
|
|
if __name__ == '__main__':
|
|
r = run(JS, timeout=300)
|
|
if not r.get('success'):
|
|
print(json.dumps(r, ensure_ascii=False)[:800]); sys.exit(1)
|
|
res = r['result']
|
|
out = os.path.join(HERE, sys.argv[1] if len(sys.argv) > 1 else '_pcb2_snap.json')
|
|
io.open(out, 'w', encoding='utf-8').write(json.dumps(res))
|
|
print(u'元件 %d / 导线 %d / 弧 %d / 过孔 %d / 铺铜 %d / 填充 %d / 焊盘 %d / 多段线 %d -> %s' % (
|
|
len(res['comps']), len(res['lines']), len(res['arcs']), len(res['vias']), len(res['pours']),
|
|
len(res['fills']), len(res['pads']), len(res['polys']), out))
|