Home > LIB_3DModel > copy
LIB_3DModel.copy() 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.
Copy 3D model
Signature
typescript
function copy(
modelUuid: string,
libraryUuid: string,
targetLibraryUuid: string,
targetClassification?: ILIB_ClassificationIndex | Array<string>,
newModelName?: string,
): Promise<string | undefined>;1
2
3
4
5
6
7
2
3
4
5
6
7
Parameters
Parameter | Type | Description |
|---|---|---|
modelUuid | string | 3D model UUID |
libraryUuid | string | Library UUID, you can use LIB_LibrariesList APIs in |
targetLibraryUuid | string | Target library UUID |
targetClassification | ILIB_ClassificationIndex | Array<string> | (Optional) Classification in the target library |
newModelName | string | (Optional) New 3D model name. If a 3D model with the same name exists in the target library, the copy will fail |
Returns
Promise<string | undefined>
UUID of the new 3D model in the target library
Example
javascript
// 1. 获取个人库 UUID(复制目标库)
const libraryUuid = await eda.lib_LibrariesList.getPersonalLibraryUuid();
// 2. 从系统库找一个 3D 模型作为复制来源
const results = await eda.lib_3DModel.search('0402', undefined, undefined, 1);
const source = results[0];
// 3. 复制到个人库,指定新名称避免同名冲突
const newName = `CopyOf_${source.name}_${Date.now()}`;
const copiedUuid = await eda.lib_3DModel.copy(
source.uuid,
source.libraryUuid,
libraryUuid,
undefined,
newName
);
// 创建类保留现场
console.log('source:', source.name, source.uuid);
console.log('copiedUuid:', copiedUuid);
console.log('newName:', newName);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22