Home > SCH_Primitive > getPrimitiveByPrimitiveId
SCH_Primitive.getPrimitiveByPrimitiveId() method
Get all properties of the primitive with the specified ID
Signature
typescript
function getPrimitiveByPrimitiveId(id: string): Promise<ISCH_Primitive | undefined>;1
Parameters
Parameter | Type | Description |
|---|---|---|
id | string | Primitive ID |
Returns
Promise<ISCH_Primitive | undefined>
All properties of the primitive
Example
javascript
// 1. 创建一个测试矩形作为查询目标(SCH 坐标单位 10mil)
const rect = await eda.sch_PrimitiveRectangle.create(1000, 1000, 200, 100);
const id = rect.getState_PrimitiveId();
// 2. 用图元 ID 反查,返回该图元的完整属性对象(图元实例)
const primitive = await eda.sch_Primitive.getPrimitiveByPrimitiveId(id);
// 3. 清理测试图元(查询类需要清理)
await eda.sch_PrimitiveRectangle.delete([id]);
console.log('primitiveType:', primitive.getState_PrimitiveType());
console.log('width:', primitive.getState_Width());
console.log('height:', primitive.getState_Height());
console.log('id match:', primitive.getState_PrimitiveId() === id);1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14