Home > IPCB_PrimitiveComponentPad > getState_ParentComponentPrimitiveId
IPCB_PrimitiveComponentPad.getState_ParentComponentPrimitiveId() method
Get the property state: parent device primitive ID
Signature
typescript
function getState_ParentComponentPrimitiveId(): string;1
Returns
string
Parent device primitive ID
Example
javascript
// 1. 放置一个测试器件
const devices = await eda.lib_Device.search('C0402');
const comp = await eda.pcb_PrimitiveComponent.create(devices[0], 1, 5000, 5000);
const compId = comp.getState_PrimitiveId();
// 2. 获取器件的焊盘图元对象,读取每个焊盘的父器件 ID
const pins = await comp.getAllPins();
const parentIds = pins.map(pin => pin.getState_ParentComponentPrimitiveId());
// 3. 清理测试器件
await eda.pcb_PrimitiveComponent.delete([compId]);
console.log('pinCount:', pins.length);
console.log('allBelongToComponent:', parentIds.every(id => id === compId));
console.log('firstPinParentId:', parentIds[0]);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15