Home > IPCB_PrimitivePour > toAsync
IPCB_PrimitivePour.toAsync() method
将图元转换为异步图元
签名
typescript
function toAsync(): IPCB_PrimitivePour;1
返回值
覆铜边框图元对象
示例
javascript
// 1. 生成本次运行专用的坐标,避免与之前保留的测试图元重合
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
// 2. 创建一个顶层铜层的覆铜边框
const polygon = eda.pcb_MathPolygon.createPolygon(['R', x, y, 500, 300, 0, 0]);
const pour = await eda.pcb_PrimitivePour.create('', 1, polygon, 'solid', false, '嘉立创示例_转异步', 5, 10, false);
// 3. 转换为异步图元
const asyncPour = pour.toAsync();
// 4. 异步模式下连续改两个属性,一次提交
asyncPour.setState_Layer(2);
asyncPour.setState_PourName('嘉立创示例_批量改名');
await asyncPour.done();
// 5. 从画布重新读取,确认批量修改已生效(保留现场供观察)
const refetched = await eda.pcb_PrimitivePour.get(pour.getState_PrimitiveId());
console.log('isAsync:', asyncPour.isAsync());
console.log('layer:', pour.getState_Layer(), '→', refetched.getState_Layer());
console.log('pourName:', pour.getState_PourName(), '→', refetched.getState_PourName());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22