Home > LIB_3DModel > copy
LIB_3DModel.copy() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
复制 3D 模型
签名
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
参数名
参数 | 类型 | 描述 |
|---|---|---|
modelUuid | string | 3D 模型 UUID |
libraryUuid | string | 库 UUID,可以使用 LIB_LibrariesList 内的接口获取 |
targetLibraryUuid | string | 目标库 UUID |
targetClassification | ILIB_ClassificationIndex | Array<string> | (可选) 目标库内的分类 |
newModelName | string | (可选) 新 3D 模型名称,如若目标库内存在重名 3D 模型将导致复制失败 |
返回值
Promise<string | undefined>
目标库内新 3D 模型的 UUID
示例
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