Home > SCH_Primitive > getPrimitiveTypeByPrimitiveId
SCH_Primitive.getPrimitiveTypeByPrimitiveId() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
获取指定 ID 的图元的图元类型
签名
typescript
function getPrimitiveTypeByPrimitiveId(id: string): Promise<ESCH_PrimitiveType | undefined>;1
参数名
参数 | 类型 | 描述 |
|---|---|---|
id | string | 图元 ID |
返回值
Promise<ESCH_PrimitiveType | undefined>
图元类型
示例
javascript
// 1. 创建一条测试导线作为查询目标(SCH 坐标单位 10mil)
const wire = await eda.sch_PrimitiveWire.create([1000, 1000, 1400, 1000], 'SIG_A');
// 2. 用图元 ID 查询类型
const type = await eda.sch_Primitive.getPrimitiveTypeByPrimitiveId(wire.getState_PrimitiveId());
// 3. 清理测试图元(查询类需要清理)
await eda.sch_PrimitiveWire.delete([wire.getState_PrimitiveId()]);
console.log('primitiveType:', type);1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10