Home > PCB_PrimitivePolyline > create
PCB_PrimitivePolyline.create() method
创建折线
签名
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
参数名
参数 | 类型 | 描述 |
|---|---|---|
net | string | 网络名称 |
layer | 层 | |
polygon | 单多边形对象 | |
lineWidth | number | (可选) 线宽 |
primitiveLock | boolean | (可选) 是否锁定 |
返回值
Promise<IPCB_PrimitivePolyline | undefined>
折线图元对象
示例
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