Home > IPCB_PrimitiveRegion > toSync
IPCB_PrimitiveRegion.toSync() method
将图元转换为同步图元
签名
typescript
function toSync(): IPCB_PrimitiveRegion;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 region = await eda.pcb_PrimitiveRegion.create(1, polygon);
const before = region.isAsync();
// 3. 转换为同步图元(保留现场供观察)
const syncRegion = region.toSync();
const after = syncRegion.isAsync();
// 4. 同步图元直接读取属性,无需提交
console.log('isAsync:', before, '→', after);
console.log('primitiveType:', syncRegion.getState_PrimitiveType());
console.log('layer:', syncRegion.getState_Layer());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17