Home > SCH_PrimitiveComponent > createNetPort
SCH_PrimitiveComponent.createNetPort() 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 Net port
Signature
typescript
function createNetPort(
direction: 'IN' | 'OUT' | 'BI',
net: string,
x: number,
y: number,
rotation?: number,
mirror?: boolean,
): Promise<ISCH_PrimitiveComponent | undefined>;1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
Parameters
Parameter | Type | Description |
|---|---|---|
direction | 'IN' | 'OUT' | 'BI' | Port direction |
net | string | Net name |
x | number | X coordinate |
y | number | Y coordinate |
rotation | number | (Optional) Rotation angle |
mirror | boolean | (Optional) Whether it is mirrored |
Returns
Promise<ISCH_PrimitiveComponent | undefined>
Device primitive object
Example
javascript
// 1. 随机坐标避免与画布已有图元重合(SCH 坐标单位 10mil)
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
// 2. 创建输入方向的端口,网络名为 SIG_IN
const port = await eda.sch_PrimitiveComponent.createNetPort(
'IN', // 端口方向:'IN' / 'OUT' / 'BI'
'嘉立创示例_SIG', // 网络名称
x, // 坐标 X
y, // 坐标 Y
0, // 旋转角度
false // 是否镜像
);
// 3. 创建类保留现场,供在画布上观察端口样式
console.log('primitiveId:', port.getState_PrimitiveId());
console.log('net:', port.getState_Net());
console.log('componentType:', port.getState_ComponentType());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18