Home > PCB_PrimitiveFill > create
PCB_PrimitiveFill.create() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
创建填充
签名
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
参数名
参数 | 类型 | 描述 |
|---|---|---|
layer | 层 | |
complexPolygon | 复杂多边形对象 | |
net | string | (可选) 网络名称 |
fillMode | (可选) 填充模式 | |
lineWidth | number | (可选) 线宽 |
primitiveLock | boolean | (可选) 是否锁定 |
返回值
Promise<IPCB_PrimitiveFill | undefined>
填充图元对象
示例
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