DMT_Pcb.copyPcb() method
复制 PCB
签名
typescript
function copyPcb(pcbUuid: string, boardName?: string): Promise<string | undefined>;1
参数名
参数 | 类型 | 描述 |
|---|---|---|
pcbUuid | string | 源 PCB UUID |
boardName | string | (可选) 新 PCB 所属板子名称,如若不指定则为游离 PCB |
返回值
Promise<string | undefined>
新 PCB UUID,如若为 undefined 则复制失败
备注
即使此处 PCB 已关联复用模块(在工程库内存在同名的复用模块符号),也不新建复用模块符号,此操作逻辑与当前编辑器前端保持一致
示例
javascript
// 1. 创建一个专用源 PCB 并等 1.5s 同步(复制前源 PCB 必须已在工作区落地)
const sourceUuid = await eda.dmt_Pcb.createPcb();
await new Promise(r => setTimeout(r, 1500));
// 2. 复制源 PCB,返回副本 UUID
const copiedUuid = await eda.dmt_Pcb.copyPcb(sourceUuid);
await new Promise(r => setTimeout(r, 1500));
// 3. 回读副本,确认名称与归属
const copyInfo = await eda.dmt_Pcb.getPcbInfo(copiedUuid);
console.log('copiedUuid:', copiedUuid);
console.log('copyName:', copyInfo?.name);
console.log('copyParentBoardName:', copyInfo?.parentBoardName);
// 4. 清理本例创建的两块 PCB(先删副本再删源),保持工程整洁
const deletedCopy = await eda.dmt_Pcb.deletePcb(copiedUuid);
console.log('deleted:', deletedCopy);
const deletedSource = await eda.dmt_Pcb.deletePcb(sourceUuid);
console.log('deleted:', deletedSource);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19