Home > IPCB_PrimitivePoured > convertToFill
IPCB_PrimitivePoured.convertToFill() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
转换到:填充图元
签名
typescript
function convertToFill(
pourFillId: IPCB_PrimitivePouredPourFill['id'],
): Promise<IPCB_PrimitiveFill | undefined>;1
2
3
2
3
参数名
参数 | 类型 | 描述 |
|---|---|---|
pourFillId |
返回值
Promise<IPCB_PrimitiveFill | undefined>
填充图元对象,无法转换或 ID 错误将返回 undefined
示例
javascript
// 1. 获取画布上已有的覆铜填充图元
const pouredList = await eda.pcb_PrimitivePoured.getAll();
if (!pouredList || pouredList.length === 0) {
console.log('说明:PCB 上没有覆铜填充,请先手动绘制覆铜并重建(设计 → 覆铜)');
return;
}
const poured = pouredList[0];
// 2. 取第一个填充子区域的 ID(本方法按 pourFillId 定位,不是图元 ID)
const pourFills = poured.getState_PourFills();
if (pourFills.length === 0) {
console.log('说明:该覆铜填充没有子区域');
return;
}
// 3. 将该子区域转换为独立填充图元(保留现场供观察)
const fill = await poured.convertToFill(pourFills[0].id);
// 4. 输出转换得到的填充图元信息
if (fill) {
console.log('primitiveType:', fill.getState_PrimitiveType());
console.log('primitiveId:', fill.getState_PrimitiveId());
} else {
console.log('说明:转换失败(返回 undefined)');
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25