Home > SCH_PrimitiveBus > create
SCH_PrimitiveBus.create() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
创建总线
签名
typescript
function create(
busName: string,
line: Array<number> | Array<Array<number>>,
color?: string | null,
lineWidth?: number | null,
lineType?: ESCH_PrimitiveLineType | null,
): Promise<ISCH_PrimitiveBus | undefined>;1
2
3
4
5
6
7
2
3
4
5
6
7
参数名
参数 | 类型 | 描述 |
|---|---|---|
busName | string | 总线名称 |
line | Array<number> | Array<Array<number>> | 多段线坐标组,每段都是连续的一组 类型 |
color | string | null | (可选) 总线颜色, |
lineWidth | number | null | (可选) 线宽,范围 |
lineType | ESCH_PrimitiveLineType | null | (可选) 线型, |
返回值
Promise<ISCH_PrimitiveBus | undefined>
总线图元对象
示例
javascript
// 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());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19