Home > ISCH_PrimitiveAttribute > getState_Key
ISCH_PrimitiveAttribute.getState_Key() method
获取属性状态:键
签名
typescript
function getState_Key(): string;1
返回值
string
键
示例
javascript
// 1. 放置一个测试器件(属性图元随器件生成,无法单独创建)
const devices = await eda.lib_Device.search('C0402');
const comp = await eda.sch_PrimitiveComponent.create(devices[0], 600, 600);
const compId = comp.getState_PrimitiveId();
// 2. 取出器件的属性图元,定位 Designator(编号)属性
const attrIds = await eda.sch_PrimitiveAttribute.getAllPrimitiveId(compId);
const attrs = await eda.sch_PrimitiveAttribute.get(attrIds);
const designator = attrs.find(a => a.getState_Key() === 'Designator');
// 3. 读取器件全部属性的 Key(属性名)
const keys = attrs.map(a => a.getState_Key());
// 4. 清理测试器件(属性图元随器件一起删除)
await eda.sch_PrimitiveComponent.delete([compId]);
console.log('keys:', keys.join(', '));1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17