English
Home > PCB_PrimitivePour > rebuildCopperRegionsByLayer
PCB_PrimitivePour.rebuildCopperRegionsByLayer() 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.
按层重建覆铜区域
Signature
typescript
function rebuildCopperRegionsByLayer(
layer: TPCB_LayersOfCopper | Array<TPCB_LayersOfCopper>,
): Promise<Array<IPCB_PrimitivePoured>>;1
2
3
2
3
Parameters
Parameter | Type | Description |
|---|---|---|
layer | TPCB_LayersOfCopper | Array<TPCB_LayersOfCopper> | 铜箔层,取值与 getAll 的 |
Returns
Promise<Array<IPCB_PrimitivePoured>>
覆铜填充图元数组(按覆铜边框分组),无重建结果的覆铜边框不会出现在返回值中
Remarks
只重建指定铜箔层上的覆铜区域,其余层的覆铜保持不变
可传入单层或多层:传数组时按其中全部层重建,同一层的覆铜只重建一次;传入空数组时不执行任何重建并返回空数组
目标层上没有覆铜区域时返回空数组,不产生任何改动;如需重建画布上全部层,请使用 rebuildAllCopperRegions
传入的层中包含内层时,这些内层的内电层覆铜也会一并重建
当前文档未激活或没有编辑权限时,本接口会抛出错误而非静默返回空数组;传入的层上没有覆铜区域属于正常情况,此时返回空数组
覆铜区域较多时本接口耗时较长,建议单独调用或在 beginCommandGroup 内成组执行 ADD since EDA v4.1.103
Example
javascript
// 1. 创建两条位于顶层(层 ID 1)的测试覆铜边框(随机坐标避免重合)
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
const polygon1 = eda.pcb_MathPolygon.createPolygon(['R', x, y, 500, 300, 0, 0]);
const polygon2 = eda.pcb_MathPolygon.createPolygon(['R', x, y + 500, 500, 300, 0, 0]);
await eda.pcb_PrimitivePour.create('GND', 1, polygon1, 'solid', false, '嘉立创示例_按层重建1', 5, 10, false);
await eda.pcb_PrimitivePour.create('GND', 1, polygon2, 'solid', false, '嘉立创示例_按层重建2', 5, 10, false);
// 2. 只重建顶层(层 ID 1)上的覆铜区域
const pouredList = await eda.pcb_PrimitivePour.rebuildCopperRegionsByLayer(1);
console.log('顶层重建数量:', pouredList.length);
// 3. 一次重建多个层(层数组中包含内层时,内层的内电层覆铜也会一并重建)
const multiLayerPouredList = await eda.pcb_PrimitivePour.rebuildCopperRegionsByLayer([1, 15]);
console.log('多层重建数量:', multiLayerPouredList.length);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15