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