Home > PCB_Document > importAutoRouteJsonFile
PCB_Document.importAutoRouteJsonFile() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
导入自动布线文件(JSON)
签名
typescript
function importAutoRouteJsonFile(autoRouteFile: File): Promise<boolean>;1
参数名
参数 | 类型 | 描述 |
|---|---|---|
autoRouteFile | File | 欲导入的 JSON 文件 |
返回值
Promise<boolean>
导入操作是否成功
备注
可以使用 读入文件
示例
javascript
// 1. 创建测试 PCB 并打开(导入作用于当前激活的 PCB)
const pcbUuid = await eda.dmt_Pcb.createPcb();
await new Promise(r => setTimeout(r, 1500));
await eda.dmt_EditorControl.openDocument(pcbUuid);
await new Promise(r => setTimeout(r, 1000));
// 2. 构造布线 JSON 文件对象(真实场景:readFileFromFileSystem 读取外部导出的文件)
const routeFile = new File([JSON.stringify({})], 'auto-route.json', { type: 'application/json' });
// 3. 导入自动布线文件
const imported = await eda.pcb_Document.importAutoRouteJsonFile(routeFile);
console.log('imported:', imported);
// 4. 清理测试 PCB
await eda.dmt_Pcb.deletePcb(pcbUuid);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