await eda.dmt_EditorControl.openDocument('9a6096762e036e23'); await new Promise(r => setTimeout(r, 1500)); const M = 10; // sch 单位 -> 记录原样 const out = {}; // U13 的引脚 for (const c of await eda.sch_PrimitiveComponent.getAll()) { if ((c.designator || '') !== 'U13') continue; out.u13 = {x: c.x, y: c.y, rot: c.rotation}; const pins = await eda.sch_PrimitiveComponent.getAllPinsByPrimitiveId(c.primitiveId); out.pins = pins.map(p => ({n: p.pinNumber, name: p.pinName, x: p.pinDotX, y: p.pinDotY})); } // 附近的导线与端口 const near = (x, y) => out.u13 && Math.abs(x - out.u13.x) < 200 && Math.abs(y - out.u13.y) < 200; out.wires = (await eda.sch_PrimitiveWire.getAll()) .filter(w => Array.isArray(w.points) && w.points.some((v,i) => i%2===0 && near(v, w.points[i+1]))) .map(w => ({pts: w.points})); out.ports = []; for (const t of ['sch_PrimitiveNetPort', 'sch_PrimitiveNetFlag', 'sch_PrimitiveNetLabel']) { if (!eda[t]) continue; try { const all = await eda[t].getAll(); for (const p of all) if (near(p.x, p.y)) out.ports.push({t, name: p.name || p.netName || p.text, x: p.x, y: p.y, rot: p.rotation}); } catch (e) { out.ports.push({t, err: String(e).slice(0,80)}); } } return out;