- 规则:铜层 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
77 行
3.7 KiB
Python
77 行
3.7 KiB
Python
# -*- coding: utf-8 -*-
|
||
u"""重载 EasyEDA 客户端页面(skill §9k/§9s):关对话框 → 删铺铜边框 → 存盘 → reload → 等 windowId 变掉。"""
|
||
import json, os, sys, time, urllib.request
|
||
HERE = os.path.dirname(os.path.abspath(__file__)); sys.path.insert(0, HERE)
|
||
from eda import run, port
|
||
JS = u"""
|
||
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
||
const nat = b => { const o={bubbles:true,cancelable:true,view:window,button:0};
|
||
for (const t of ['pointerdown','mousedown','pointerup','mouseup','click'])
|
||
b.dispatchEvent(new (t.startsWith('pointer')?PointerEvent:MouseEvent)(t,o)); };
|
||
for (const b of document.querySelectorAll('button'))
|
||
if ((b.innerText||'').trim()==='取消' && b.offsetParent!==null) { nat(b); await sleep(800); }
|
||
await eda.dmt_EditorControl.openDocument('942ed1560d81c1e7');
|
||
await sleep(1200);
|
||
let n = 0;
|
||
for (const o of await eda.pcb_PrimitivePour.getAll()) { await eda.pcb_PrimitivePour.delete(o.primitiveId); n++; }
|
||
await eda.pcb_Document.save();
|
||
await sleep(1500);
|
||
window.onbeforeunload = null;
|
||
setTimeout(() => location.reload(true), 300);
|
||
return {deletedPours: n};
|
||
"""
|
||
def wid():
|
||
try:
|
||
with urllib.request.urlopen('http://127.0.0.1:%d/health' % port(), timeout=3) as r:
|
||
return json.loads(r.read()).get('activeWindowId')
|
||
except Exception:
|
||
return None
|
||
w0 = wid()
|
||
r = run(JS, timeout=60)
|
||
print(u'重载前 windowId %s,删铺铜边框 %s' % (w0, (r.get('result') or {}).get('deletedPours')))
|
||
COUNT_JS = u"""
|
||
await eda.dmt_EditorControl.openDocument('942ed1560d81c1e7');
|
||
await new Promise(r => setTimeout(r, 9000));
|
||
let nc=0, nl=0, nv=0, npad=0;
|
||
for (const c of await eda.pcb_PrimitiveComponent.getAll()) nc++;
|
||
for (const l of await eda.pcb_PrimitiveLine.getAll()) nl++;
|
||
for (const v of await eda.pcb_PrimitiveVia.getAll()) nv++;
|
||
for (const p of await eda.pcb_PrimitivePad.getAll()) npad++;
|
||
return {doc: (await eda.dmt_Pcb.getCurrentPcbInfo() || {}).name, nc, nl, nv, npad};
|
||
"""
|
||
|
||
|
||
def assert_alive():
|
||
u"""⚠⚠ 重载之后**必须**先数一遍图元,确认桥接和文档真的接上了再往下走。
|
||
|
||
2026-09-07 就是漏了这一步把载板弄丢的:重载回来后铜层读回全 0
|
||
(skill §9ae 那个陈旧上下文),而紧接着跑的 `pcb2_pour.py --push`
|
||
又在那个状态下调了一次 `save()` —— 把“空”写回了文档,
|
||
301 件的下板没事、223 件的载板只剩下丝印和板框,只能走工程历史恢复。
|
||
|
||
“重载成功”的判据不是 windowId 变了,是**图元数不为零**。
|
||
不过关、绝不允许后面任何一步 save()。
|
||
"""
|
||
r = run(COUNT_JS, timeout=120)
|
||
if not r.get('success'):
|
||
sys.exit(u'!! 重载后数图元失败,**不要再跑任何会 save() 的脚本**: %s'
|
||
% json.dumps(r, ensure_ascii=False)[:400])
|
||
d = r['result']
|
||
print(u'重载后回查:%s 元件 %s / 导线 %s / 过孔 %s / 焊盘 %s'
|
||
% (d.get('doc'), d.get('nc'), d.get('nl'), d.get('nv'), d.get('npad')))
|
||
if not d.get('nc') or not d.get('nl') or not d.get('npad'):
|
||
sys.exit(u'!! 铜层读回 0 —— 桥接与文档失同步(skill §9ae)。\n'
|
||
u' **立刻停手,不要 save(),不要跑 pcb2_pour.py** —— 那一步会把空写回去。\n'
|
||
u' 先 API Gateway → 重新连接,不行就重启客户端,再跑一次本脚本确认数字回来了。')
|
||
|
||
|
||
for i in range(30):
|
||
time.sleep(5)
|
||
w = wid()
|
||
if w and w != w0:
|
||
print(u'已重载,新 windowId %s(%d s)' % (w, (i + 1) * 5))
|
||
time.sleep(10)
|
||
assert_alive()
|
||
sys.exit(0)
|
||
sys.exit(u'!! 150 s 内 windowId 没变,重载没成功')
|