Home > IPCB_PrimitiveComponentPad > done
IPCB_PrimitiveComponentPad.done() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
将对图元的更改应用到画布
签名
typescript
function done(): Promise<IPCB_PrimitiveComponentPad>;1
返回值
Promise<IPCB_PrimitiveComponentPad>
器件焊盘图元对象
示例
javascript
// 1. 放置一个测试器件并取第一个焊盘(随机坐标,避免与历史保留图元重合)
const x = 5000 + Math.floor(Math.random() * 50000);
const devices = await eda.lib_Device.search('C0402');
const comp = await eda.pcb_PrimitiveComponent.create(devices[0], 1, x, 5000);
const pin = (await comp.getAllPins())[0];
// 2. 读取修改前的位置
const before = pin.getState_X();
// 3. 异步模式修改焊盘 X 坐标后一次提交
const asyncPin = pin.toAsync();
asyncPin.setState_X(before + 100);
await asyncPin.done();
// 4. 重新获取器件焊盘,验证修改已在画布生效
const refreshed = (await eda.pcb_PrimitiveComponent.get([comp.getState_PrimitiveId()]))[0];
const after = (await refreshed.getAllPins())[0].getState_X();
console.log('before:', before, '→ after:', after);
console.log('moved:', after === before + 100);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20