Home > SCH_PrimitiveWire > create
SCH_PrimitiveWire.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 Wire
Signature
function create(
line: Array<number> | Array<Array<number>>,
net?: string,
color?: string | null,
lineWidth?: number | null,
lineType?: ESCH_PrimitiveLineType | null,
): Promise<ISCH_PrimitiveWire | undefined>;2
3
4
5
6
7
Parameters
Parameter | Type | Description |
|---|---|---|
line | Array<number> | Array<Array<number>> | Polyline coordinate group. Each segment is a continuous line described by |
net | string | (Optional) Net name. If not specified, the following rules apply: 1. If no coordinate falls on any primitive, the empty net is used by default; 2. If one coordinate point is on a primitive of a net, the net of that primitive is followed; 3. If multiple coordinate points are on primitives of different nets, the creation fails. If specified, the following rules apply: 1. If one or more coordinate points are on primitives of other nets, and those other primitives do not explicitly (usually via net labels or net ports) specify a net, they follow the specified net; 2. If other primitives have specified a net, the creation fails |
color | string | null | (Optional) Wire color, |
lineWidth | number | null | (Optional) Line width, range |
lineType | ESCH_PrimitiveLineType | null | (Optional) Line type. |
Returns
Promise<ISCH_PrimitiveWire | undefined>
Wire primitive object
Example
// 1. 生成随机起点坐标,避免与画布上已有的导线重合(SCH 坐标单位 10mil)
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
// 2. 创建一条两段相连的 L 形导线:先向右再向上,段与段必须首尾相连且各自水平或垂直
const wire = await eda.sch_PrimitiveWire.create(
[[x, y, x + 400, y], [x + 400, y, x + 400, y + 200]],
'SIG_A', // 网络名称(自由字符串,未指定时按落点自动推断)
'#FF0000', // 导线颜色
6, // 线宽(范围 1-10)
1 // 线型:1 = DASHED(虚线)
);
// 3. 创建类保留现场,不删除图元;Line 读回是画布规格化坐标(端点顺序可能与传入相反),只打印不做断言
console.log('primitiveId:', wire.getState_PrimitiveId());
console.log('primitiveType:', wire.getState_PrimitiveType());
console.log('net:', wire.getState_Net());
console.log('color:', wire.getState_Color());
console.log('lineWidth:', wire.getState_LineWidth());
console.log('line:', JSON.stringify(wire.getState_Line()));2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20