Home > ISCH_PrimitivePin > done
ISCH_PrimitivePin.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<ISCH_PrimitivePin>;1
Returns
Promise<ISCH_PrimitivePin>
Pin primitive object
Example
javascript
// 0. 确保当前文档是符号编辑器:优先复用测试符号,没有则新建后打开
const libUuid = await eda.lib_LibrariesList.getPersonalLibraryUuid();
const found = await eda.lib_Symbol.search('嘉立创示例_Pin测试符号', libUuid);
const symUuid = found[0] ? found[0].uuid : await eda.lib_Symbol.create(libUuid, '嘉立创示例_Pin测试符号');
await eda.lib_Symbol.openInEditor(symUuid, libUuid);
// 1. 生成本次运行专用的坐标,避免与之前保留的测试引脚重合
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
// 2. 在符号画布上创建一个测试引脚
const pin = await eda.sch_PrimitivePin.create(x, y, '1', 'CLK', 0, 10, null, 'None', 'IN');
// 3. 异步模式下连续修改编号和名称(此时画布尚未变化)
const asyncPin = pin.toAsync();
asyncPin.setState_PinNumber('A1');
asyncPin.setState_PinName('SYS_CLK');
// 4. done() 一次性提交两处修改
const applied = await asyncPin.done();
// 5. 从画布重新取引脚,确认修改已生效(保留现场供观察)
const refetched = await eda.sch_PrimitivePin.get(pin.getState_PrimitiveId());
console.log('applied number:', refetched.getState_PinNumber());
console.log('applied name:', refetched.getState_PinName());
console.log('done returns same primitive:', applied.getState_PrimitiveId() === pin.getState_PrimitiveId());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27