Home > SCH_PrimitiveBus > create
SCH_PrimitiveBus.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 bus
Signature
function create(
busName: string,
line: Array<number> | Array<Array<number>>,
color?: string | null,
lineWidth?: number | null,
lineType?: ESCH_PrimitiveLineType | null,
): Promise<ISCH_PrimitiveBus | undefined>;2
3
4
5
6
7
Parameters
Parameter | Type | Description |
|---|---|---|
busName | string | Bus name |
line | Array<number> | Array<Array<number>> | Polyline coordinate group. Each segment is a continuous line described by |
color | string | null | (Optional) Bus color. |
lineWidth | number | null | (Optional) Line width, range |
lineType | ESCH_PrimitiveLineType | null | (Optional) Line type. |
Returns
Promise<ISCH_PrimitiveBus | undefined>
Bus 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 bus = await eda.sch_PrimitiveBus.create(
'DATA[0..7]',
[[x, y, x + 400, y], [x + 400, y, x + 400, y + 200]],
'#FF0000', // 总线颜色
6, // 线宽(范围 1-10)
1 // 线型:1 = DASHED(虚线)
);
// 3. 创建类保留现场,不删除图元
console.log('primitiveId:', bus.getState_PrimitiveId());
console.log('primitiveType:', bus.getState_PrimitiveType());
console.log('busName:', bus.getState_BusName());
console.log('color:', bus.getState_Color());
console.log('lineWidth:', bus.getState_LineWidth());2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19