Home > IPCB_PrimitiveImage > toSync
IPCB_PrimitiveImage.toSync() method
Convert Primitive to Sync primitive
Signature
typescript
function toSync(): IPCB_PrimitiveImage;1
Returns
Image primitive object
Example
javascript
// 1. 生成本次运行专用的坐标,创建一个 400 x 300 的顶层图像
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
const complexPolygon = eda.pcb_MathPolygon.createComplexPolygon([0, 0, 'L', 200, 0, 200, 150, 0, 150]);
const image = await eda.pcb_PrimitiveImage.create(x, y, complexPolygon, 1, 400, 300, 0, false, false);
const before = image.isAsync();
// 2. 转换为同步图元(保留现场供观察)
const syncImage = image.toSync();
const after = syncImage.isAsync();
// 3. 同步图元直接读取属性,无需提交
console.log('isAsync:', before, '→', after);
console.log('primitiveType:', syncImage.getState_PrimitiveType());
console.log('layer:', syncImage.getState_Layer());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15