Home > IPCB_PrimitivePad > reset
IPCB_PrimitivePad.reset() 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.
Reset the async primitive to the current canvas state
Signature
typescript
function reset(): Promise<IPCB_PrimitivePad>;1
Returns
Promise<IPCB_PrimitivePad>
Pad primitive object
Example
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. 异步模式下把旋转改成 45 度(尚未提交)
const a = pad.toAsync();
a.setState_Rotation(45);
// 3. 重置:丢弃未提交的修改,回到画布当前状态
await a.reset();
// 4. 从画布重新读取,确认旋转仍是 0(reset 后要以重新 get() 的结果为准)
const ref = await eda.pcb_PrimitivePad.get(pad.getState_PrimitiveId());
// 5. 清理测试图元
await eda.pcb_PrimitivePad.delete([pad.getState_PrimitiveId()]);
console.log('rotationAfterReset:', ref.getState_Rotation());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18