Home > PCB_PrimitiveFill > create
PCB_PrimitiveFill.create() 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.
Create a fill
Signature
typescript
function create(
layer: TPCB_LayersOfFill,
complexPolygon: IPCB_Polygon,
net?: string,
fillMode?: EPCB_PrimitiveFillMode,
lineWidth?: number,
primitiveLock?: boolean,
): Promise<IPCB_PrimitiveFill | undefined>;1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
Parameters
Parameter | Type | Description |
|---|---|---|
layer | Layer | |
complexPolygon | Complex polygon object | |
net | string | (Optional) Net name |
fillMode | (Optional) Fill mode | |
lineWidth | number | (Optional) Line width |
primitiveLock | boolean | (Optional) Whether it is locked |
Returns
Promise<IPCB_PrimitiveFill | undefined>
Fill primitive object
Example
javascript
// 1. 生成随机基准坐标,避免与画布上已有的填充重合
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
// 2. 构造矩形轮廓(宽 500mil、高 300mil),填充轮廓必须是 MathPolygon 对象
const polygon = eda.pcb_MathPolygon.createPolygon(['R', x, y, 500, 300, 0, 0]);
// 3. 在顶层铜层(1)创建实心填充(SOLID=0),不挂网络,不锁定
const fill = await eda.pcb_PrimitiveFill.create(1, polygon, '', 0, 10, false);
// 4. 创建类保留现场,不删除图元
console.log('primitiveId:', fill.getState_PrimitiveId());
console.log('layer:', fill.getState_Layer());
console.log('fillMode:', fill.getState_FillMode());
console.log('net:', fill.getState_Net());
console.log('primitiveType:', fill.getState_PrimitiveType());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16