English
Home > PCB_PrimitivePour > rebuildCopperRegions
PCB_PrimitivePour.rebuildCopperRegions() 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 rebuildCopperRegions(primitiveIds?: Array<string>): Promise<Array<IPCB_PrimitivePoured>>;1
Parameters
Parameter | Type | Description |
|---|---|---|
primitiveIds | Array<string> | (Optional) 覆铜边框图元 ID 数组,如若未传入则重建当前覆铜边框关联的全部覆铜区域 |
Returns
Promise<Array<IPCB_PrimitivePoured>>
覆铜填充图元数组(按覆铜边框分组),无重建结果的覆铜边框不会出现在返回值中
Remarks
只重建**覆铜边框图元关联**的覆铜区域,即由 create 放置的覆铜边框所生成的填充
**不包含内电层覆铜**:内层信号层的覆铜不在本接口的重建范围内,需要重建内层覆铜请使用 rebuildAllCopperRegions 或 rebuildCopperRegionsByLayer ADD since EDA v5
Example
javascript
// 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]);
const pour1 = await eda.pcb_PrimitivePour.create('GND', 1, polygon1, 'solid', false, '嘉立创示例_批量重建1', 5, 10, false);
const pour2 = await eda.pcb_PrimitivePour.create('GND', 1, polygon2, 'solid', false, '嘉立创示例_批量重建2', 5, 10, false);
// 2. 传入图元 ID 数组:只重建这两条覆铜的填充
const pouredList = await eda.pcb_PrimitivePour.rebuildCopperRegions([
pour1.getState_PrimitiveId(),
pour2.getState_PrimitiveId(),
]);
// 3. 不传参:重建画布上所有覆铜边框关联的覆铜区域(不含内电层覆铜)
const allPouredList = await eda.pcb_PrimitivePour.rebuildCopperRegions();
// 4. 读取重建结果(按覆铜边框分组,重建不出填充的覆铜不在返回值中)
console.log('pouredList length:', pouredList.length);
console.log('allPouredList length:', allPouredList.length);
if (pouredList.length > 0) {
console.log('所属覆铜边框 ID:', pouredList[0].getState_PourPrimitiveId());
console.log('所属铜箔层:', pouredList[0].getState_Layer());
console.log('填充子区域数量:', pouredList[0].getState_PourFills().length);
}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