LIB_Cbb.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 Reuse block
Signature
typescript
function copy(
cbbUuid: string,
libraryUuid: string,
targetLibraryUuid: string,
targetClassification?: ILIB_ClassificationIndex | Array<string>,
newCbbName?: string,
): Promise<string | undefined>;1
2
3
4
5
6
7
2
3
4
5
6
7
Parameters
Parameter | Type | Description |
|---|---|---|
cbbUuid | string | Reuse block 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 |
newCbbName | string | (Optional) New reuse block name. If a reuse block with the same name exists in the target library, the copy will fail |
Returns
Promise<string | undefined>
UUID of the new reuse block in the target library
Example
javascript
// 1. 获取系统库与个人库 UUID
const systemLib = await eda.lib_LibrariesList.getSystemLibraryUuid();
const personalLib = await eda.lib_LibrariesList.getPersonalLibraryUuid();
// 2. 从系统库找一个复用模块作为复制来源
const results = await eda.lib_Cbb.search('', systemLib, undefined, 1);
const source = results[0];
// 3. 复制到个人库,指定新名称避免同名冲突(分类传 [] = 不分类)
const newName = `嘉立创示例_复制_${Date.now()}`;
const copiedUuid = await eda.lib_Cbb.copy(source.uuid, systemLib, personalLib, [], 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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17