Home > SCH_PrimitiveAttribute > getAllPrimitiveId
SCH_PrimitiveAttribute.getAllPrimitiveId() 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.
Get all Property primitive IDs
Signature
typescript
function getAllPrimitiveId(parentPrimitiveId?: string): Promise<Array<string>>;1
Parameters
Parameter | Type | Description |
|---|---|---|
parentPrimitiveId | string | (Optional) Parent primitive ID |
Returns
Promise<Array<string>>
Array of Property primitive IDs
Remarks
If no parent primitive ID is passed, all attribute primitives in the sheet will be obtained
Example
javascript
// 1. 放置一个测试器件(属性图元随器件生成,无法单独创建)
const devices = await eda.lib_Device.search('');
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
const comp = await eda.sch_PrimitiveComponent.create(devices[0], x, y);
const compId = comp.getState_PrimitiveId();
// 2. 传父图元 ID,只拿该器件的属性图元 ID
const compAttrIds = await eda.sch_PrimitiveAttribute.getAllPrimitiveId(compId);
// 3. 不传参数,拿当前图页全部属性图元 ID(含器件属性与独立网络标签等)
const allIds = await eda.sch_PrimitiveAttribute.getAllPrimitiveId();
// 4. 清理测试器件(属性图元随器件一起删除)
await eda.sch_PrimitiveComponent.delete([compId]);
console.log('component attr ids:', compAttrIds.length);
console.log('page total attr ids:', allIds.length);
console.log('component ids all in page list:', compAttrIds.every(id => allIds.includes(id)));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