DMT_Pcb.copyPcb() method
Copy PCB
Signature
typescript
function copyPcb(pcbUuid: string, boardName?: string): Promise<string | undefined>;1
Parameters
Parameter | Type | Description |
|---|---|---|
pcbUuid | string | Source PCB UUID |
boardName | string | (Optional) Name of the board the new PCB belongs to. If not specified, it is a free PCB |
Returns
Promise<string | undefined>
New PCB UUID. If it is undefined, the copy failed
Remarks
Even if the PCB here is already associated with a reuse block (a reuse block symbol with the same name exists in the project library), no new reuse block symbol will be created. This operation logic is consistent with the current editor front end
Example
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