Home > ISCH_PrimitiveRectangle > toAsync
ISCH_PrimitiveRectangle.toAsync() method
将图元转换为异步图元
签名
typescript
function toAsync(): ISCH_PrimitiveRectangle;1
返回值
矩形图元对象
示例
javascript
// 1. 生成本次运行专用的坐标,避免与之前保留的测试矩形重合
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
// 2. 创建一个测试矩形(创建后默认处于异步模式)
const rect = await eda.sch_PrimitiveRectangle.create(x, y, 200, 100);
// 3. 先切换到同步模式,再转回异步模式,确认可来回切换
rect.toSync();
const asyncRect = rect.toAsync();
// 4. 异步模式下批量修改尺寸,一次提交
asyncRect.setState_Width(300);
asyncRect.setState_Height(150);
await asyncRect.done();
// 5. 从画布重新读取,确认修改已生效(保留现场供观察)
const refetched = await eda.sch_PrimitiveRectangle.get(rect.getState_PrimitiveId());
console.log('isAsync after toAsync:', rect.isAsync());
console.log('width:', 200, '→', refetched.getState_Width());
console.log('height:', 100, '→', refetched.getState_Height());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