Home > ISCH_PrimitiveRectangle > toSync
ISCH_PrimitiveRectangle.toSync() method
Convert Primitive to Sync primitive
Signature
typescript
function toSync(): ISCH_PrimitiveRectangle;1
Returns
Rectangle primitive object
Example
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. 转换为同步图元
const syncRect = rect.toSync();
// 4. 同步模式下把宽扩大到 300,立即生效,无需 done()
syncRect.setState_Width(300);
// 5. 从画布重新读取,确认修改已生效(保留现场供观察)
const refetched = await eda.sch_PrimitiveRectangle.get(rect.getState_PrimitiveId());
console.log('isAsync after toSync:', rect.isAsync());
console.log('width:', 200, '→', refetched.getState_Width());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