Home > SCH_Document > autoRouting
SCH_Document.autoRouting() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
自动布线
签名
typescript
function autoRouting(props?: {
uuids?: undefined | string[];
netlist?:
| undefined
| {
component: Record<
string,
{
pinInfoMap: Record<
string,
{
name: string;
number: string;
net: string;
props: { 'Pin Number': string };
}
>;
}
>;
};
designatorDeviceTypeMap?:
| undefined
| Record<
string,
| 'resistor'
| 'capacitor'
| 'inductive'
| 'diode'
| 'triode'
| 'oscillator'
| 'chip'
| 'otherDevice'
>;
}): Promise<any>;1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
参数名
参数 | 类型 | 描述 |
|---|---|---|
props | { uuids?: undefined | string[]; netlist?: undefined | { component: Record<string, { pinInfoMap: Record<string, { name: string; number: string; net: string; props: { 'Pin Number': string } }> }> }; designatorDeviceTypeMap?: undefined | Record<string, 'resistor' | 'capacitor' | 'inductive' | 'diode' | 'triode' | 'oscillator' | 'chip' | 'otherDevice'> } | (可选) 自动布线参数 |
返回值
Promise<any>
自动布线结果
备注
如不传入任何参数,将对所有未布线的网络进行自动布线
示例
javascript
// 1. 创建测试原理图并打开
const schematicUuid = await eda.dmt_Schematic.createSchematic();
await new Promise(r => setTimeout(r, 1000));
const schInfo = await eda.dmt_Schematic.getSchematicInfo(schematicUuid);
await eda.dmt_EditorControl.openDocument(schInfo.page[0].uuid);
await new Promise(r => setTimeout(r, 800));
// 2. 放置两个测试器件并取第一个引脚的坐标(关键字搜索当前版本异常,按 C 编号反查器件)
const devices = await eda.lib_Device.searchByProperties({ supplierId: 'C1523' }, undefined, undefined, undefined, 5, 1);
const sysLibUuid = await eda.lib_LibrariesList.getSystemLibraryUuid();
const device = { libraryUuid: sysLibUuid, uuid: devices[0].uuid };
const comp1 = await eda.sch_PrimitiveComponent.create(device, 800, 800);
const comp2 = await eda.sch_PrimitiveComponent.create(device, 1600, 800);
const pin1 = (await comp1.getAllPins())[0];
const pin2 = (await comp2.getAllPins())[0];
// 3. 在两个引脚上放同名接地标志,构成一个跨器件的 GND 网络
const flag1 = await eda.sch_PrimitiveComponent.createNetFlag('Ground', 'GND', pin1.getState_X(), pin1.getState_Y());
const flag2 = await eda.sch_PrimitiveComponent.createNetFlag('Ground', 'GND', pin2.getState_X(), pin2.getState_Y());
console.log('netFlagIds:', flag1.getState_PrimitiveId(), flag2.getState_PrimitiveId());
// 4. 统计布线前导线数,执行自动布线后再统计一次
const wiresBefore = (await eda.sch_PrimitiveWire.getAllPrimitiveId()).length;
const result = await eda.sch_Document.autoRouting();
const wiresAfter = (await eda.sch_PrimitiveWire.getAllPrimitiveId()).length;
console.log('result:', result);
console.log('wiresBefore:', wiresBefore, 'wiresAfter:', wiresAfter);
// 5. 清理测试原理图(器件与网络标志随文档一起删除)
await new Promise(r => setTimeout(r, 1500));
await eda.dmt_Schematic.deleteSchematic(schematicUuid);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31