Home > PCB_Layer > getAllLayers
PCB_Layer.getAllLayers() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
获取所有图层的详细属性
签名
typescript
function getAllLayers(): Promise<Array<IPCB_LayerItem>>;1
返回值
Promise<Array<IPCB_LayerItem>>
所有图层的详细属性
示例
javascript
// 1. 一次性取回当前 PCB 的全部图层
const layers = await eda.pcb_Layer.getAllLayers();
// 2. 查看顶层(TOP=1)的典型属性
const top = layers.find(l => l.id === 1);
// 3. 统计信号层(铜箔层)数量
const copperCount = layers.filter(l => l.type === 'SIGNAL').length;
console.log('totalCount:', layers.length);
console.log('topLayerName:', top?.name);
console.log('topLayerColor:', top?.color);
console.log('topLayerLocked:', top?.locked);
console.log('copperLayerCount:', copperCount);1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14