Home > IPCB_PrimitiveString > toAsync
IPCB_PrimitiveString.toAsync() method
将图元转换为异步图元
签名
typescript
function toAsync(): IPCB_PrimitiveString;1
返回值
文本图元对象
示例
javascript
// 1. 生成本次运行专用的坐标,避免与之前保留的测试图元重合
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
// 2. 在顶层丝印(3)放置一行文本
const str = await eda.pcb_PrimitiveString.create(3, x, y, '嘉立创示例_TEXT', 'default', 45, 6, 3, 0, false, 0, false, false);
// 3. 切换异步模式后批量修改:改内容 + 加大字号
const asyncStr = str.toAsync();
asyncStr.setState_Text('嘉立创示例_批量');
asyncStr.setState_FontSize(60);
await asyncStr.done();
// 4. 从画布重新读取,确认批量修改已生效(保留现场供观察)
const refetched = await eda.pcb_PrimitiveString.get(str.getState_PrimitiveId());
console.log('text:', refetched.getState_Text());
console.log('fontSize:', refetched.getState_FontSize());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