Home > PCB_Layer > setTheNumberOfCopperLayers
PCB_Layer.setTheNumberOfCopperLayers() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Set Number of copper layers
Signature
typescript
function setTheNumberOfCopperLayers(numberOfLayers: TPCB_NumberOfCopperLayers): Promise<boolean>;1
Parameters
Parameter | Type | Description |
|---|---|---|
numberOfLayers | Number of copper layers |
Returns
Promise<boolean>
Whether the operation is successful
Remarks
A newly created PCB document has two copper layers by default
Example
javascript
// 1. 记录调整前的信号层(铜箔层)数量
const before = (await eda.pcb_Layer.getAllLayers()).filter(l => l.type === 'SIGNAL').length;
// 2. 将铜箔层数调整为 4 层,新增 INNER_1(15)、INNER_2(16)两个内层
const setResult = await eda.pcb_Layer.setTheNumberOfCopperLayers(4);
// 3. 确认内层已加入图层列表
const afterLayers = await eda.pcb_Layer.getAllLayers();
const after = afterLayers.filter(l => l.type === 'SIGNAL').length;
const inner1 = afterLayers.find(l => l.id === 15);
// 4. 恢复为 2 层板,移除空的内层(内层上有图元时无法减少层数)
const restoreResult = await eda.pcb_Layer.setTheNumberOfCopperLayers(2);
console.log('setResult:', setResult);
console.log('copperCountBefore:', before, '→ copperCountAfter:', after);
console.log('inner1Name:', inner1?.name);
console.log('restoreResult:', restoreResult);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