Home > PCB_PrimitivePolyline > create
PCB_PrimitivePolyline.create() method
Create a polyline
Signature
typescript
function create(
net: string,
layer: TPCB_LayersOfLine,
polygon: IPCB_Polygon,
lineWidth?: number,
primitiveLock?: boolean,
): Promise<IPCB_PrimitivePolyline | undefined>;1
2
3
4
5
6
7
2
3
4
5
6
7
Parameters
Parameter | Type | Description |
|---|---|---|
net | string | Net name |
layer | Layer | |
polygon | Single polygon object | |
lineWidth | number | (Optional) Line width |
primitiveLock | boolean | (Optional) Whether it is locked |
Returns
Promise<IPCB_PrimitivePolyline | undefined>
Polyline primitive object
Example
javascript
// 1. 生成随机起点坐标,避免与画布上已有的折线重合
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
// 2. 用 pcb_MathPolygon.createPolygon 构造折线路径:起点 → 右移 500 → 上移 300 的 L 形三顶点折线
const polygon = eda.pcb_MathPolygon.createPolygon([x, y, 'L', x + 500, y, x + 500, y + 300]);
// 3. 在顶层铜层创建折线:空网络,线宽 10mil,不锁定
const polyline = await eda.pcb_PrimitivePolyline.create('', 1, polygon, 10, false);
// 4. 创建类保留现场,不删除图元
console.log('primitiveId:', polyline.getState_PrimitiveId());
console.log('primitiveType:', polyline.getState_PrimitiveType());
console.log('lineWidth:', polyline.getState_LineWidth());
console.log('layer:', polyline.getState_Layer());
console.log('polygon source:', polyline.getState_Polygon().getSource().join(', '));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