Home > IPCB_PrimitiveFill > toSync
IPCB_PrimitiveFill.toSync() method
将图元转换为同步图元
签名
typescript
function toSync(): IPCB_PrimitiveFill;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 fill = await eda.pcb_PrimitiveFill.create(1, polygon, '', 0, 10, false);
const before = fill.isAsync();
// 3. 转换为同步图元(保留现场供观察)
const syncFill = fill.toSync();
const after = syncFill.isAsync();
// 4. 同步图元直接读取属性,无需提交
console.log('isAsync:', before, '→', after);
console.log('primitiveType:', syncFill.getState_PrimitiveType());
console.log('layer:', syncFill.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