Home > IPCB_PrimitiveLine > toAsync
IPCB_PrimitiveLine.toAsync() method
Convert Primitive to Async primitive
Signature
typescript
function toAsync(): IPCB_PrimitiveLine;1
Returns
Line primitive object
Example
javascript
// 1. 生成本次运行专用的坐标,避免与之前保留的测试走线重合
const x = 52000 + (Math.floor(Math.random() * 100000));
const y = 2000 + (Math.floor(Math.random() * 100000));
// 2. 创建一条测试直线,切换到同步模式,让模式变化可观察
const line = await eda.pcb_PrimitiveLine.create('', 1, x, y, x + 600, y, 10);
line.toSync();
// 3. 转换为异步图元
const asyncLine = line.toAsync();
// 4. 异步模式下累计修改并提交
asyncLine.setState_LineWidth(24);
await asyncLine.done();
// 5. 从画布重新读取,确认提交生效(保留现场供观察)
const refetched = await eda.pcb_PrimitiveLine.get(line.getState_PrimitiveId());
console.log('isAsync after toAsync:', line.isAsync());
console.log('lineWidth:', 10, '→', refetched.getState_LineWidth());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