Home > IPCB_PrimitivePad > toSync
IPCB_PrimitivePad.toSync() method
将图元转换为同步图元
签名
typescript
public toSync(): IPCB_PrimitivePad;1
返回值
焊盘图元对象
示例
javascript
// 1. 在顶层放置一个圆形贴片焊盘
const x = 3000 + Math.floor(Math.random() * 100000);
const pad = await eda.pcb_PrimitivePad.create(1, '1', x, 3000, 0, ['ELLIPSE', 60, 60], '', null, 0, 0, 0, false, 0);
// 2. 切换为同步图元(返回同一图元的同步形态)
const syncPad = pad.toSync();
// 3. 同步模式下直接修改位置,无需 done() 立即生效
syncPad.setState_X(x + 300);
// 4. 从画布重新读取,确认修改已落画布(保留现场供观察)
const ref = await eda.pcb_PrimitivePad.get(pad.getState_PrimitiveId());
console.log('isAsync:', syncPad.isAsync());
console.log('x:', x, '→', ref.getState_X());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15