Home > PCB_Net > getAllPrimitivesByNet
PCB_Net.getAllPrimitivesByNet() 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 primitives associated with the specified net
Signature
typescript
function getAllPrimitivesByNet(
net: string,
primitiveTypes?: Array<EPCB_PrimitiveType>,
): Promise<Array<IPCB_Primitive>>;1
2
3
4
2
3
4
Parameters
Parameter | Type | Description |
|---|---|---|
net | string | Net name |
primitiveTypes | Array<EPCB_PrimitiveType> | (Optional) Array of primitive types. If the specified primitive type has no net property, the returned data will always be empty |
Returns
Promise<Array<IPCB_Primitive>>
Array of primitive objects
Example
javascript
// 1. 创建带网络名的过孔,让 PCB 中出现可查询的网络
const via = await eda.pcb_PrimitiveVia.create('嘉立创示例_NET1', 2000, 2000, 20, 40);
// 2. 获取该网络关联的全部图元
const primitives = await eda.pcb_Net.getAllPrimitivesByNet('嘉立创示例_NET1');
// 3. 查看图元数据对象的典型字段(pcbItemPrimitiveType 为图元类型名称)
const first = primitives[0];
// 4. 清理测试图元(查询类需要清理)
await eda.pcb_PrimitiveVia.delete([via.getState_PrimitiveId()]);
console.log('primitiveCount:', primitives.length);
console.log('firstItemPrimitiveType:', first?.pcbItemPrimitiveType);
console.log('firstNet:', first?.net);
console.log('firstCenter:', first?.center);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16