Home > IPCB_PrimitiveComponentPad > done
IPCB_PrimitiveComponentPad.done() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Apply the changes to the primitives to the canvas
Signature
typescript
function done(): Promise<IPCB_PrimitiveComponentPad>;1
Returns
Promise<IPCB_PrimitiveComponentPad>
Device pad primitive object
Example
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