Home > LIB_Device > modify
LIB_Device.modify() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
修改器件
签名
function modify(
deviceUuid: string,
libraryUuid: string,
deviceName?: string,
classification?: ILIB_ClassificationIndex | Array<string> | null,
association?: {
symbolUuid?: string;
symbol?: { uuid: string; libraryUuid: string };
footprintUuid?: string | null;
footprint?: { uuid: string; libraryUuid: string } | null;
model3D?: { uuid: string; libraryUuid: string } | null;
imageData?: File | Blob | null;
},
description?: string | null,
property?: {
name?: string | null;
designator?: string;
addIntoBom?: boolean;
addIntoPcb?: boolean;
net?: string;
manufacturer?: string | null;
manufacturerId?: string | null;
supplier?: string | null;
supplierId?: string | null;
otherProperty?: Record<string, boolean | number | string | undefined | null>;
},
): Promise<boolean>;2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
参数名
参数 | 类型 | 描述 |
|---|---|---|
deviceUuid | string | 器件 UUID |
libraryUuid | string | 库 UUID,可以使用 LIB_LibrariesList 内的接口获取 |
deviceName | string | (可选) 器件名称 |
classification | ILIB_ClassificationIndex | Array<string> | null | (可选) 分类 |
association | { symbolUuid?: string; symbol?: { uuid: string; libraryUuid: string }; footprintUuid?: string | null; footprint?: { uuid: string; libraryUuid: string } | null; model3D?: { uuid: string; libraryUuid: string } | null; imageData?: File | Blob | null } | (可选) 关联符号、封装、图像 |
description | string | null | (可选) 描述 |
property | { name?: string | null; designator?: string; addIntoBom?: boolean; addIntoPcb?: boolean; net?: string; manufacturer?: string | null; manufacturerId?: string | null; supplier?: string | null; supplierId?: string | null; otherProperty?: Record<string, boolean | number | string | undefined | null> } | (可选) 其它属性 |
返回值
Promise<boolean>
操作是否成功
备注
如希望清除某些属性,则将其的值设置为 null
示例
// 1. 获取个人库 UUID 并新建修改对象
const libraryUuid = await eda.lib_LibrariesList.getPersonalLibraryUuid();
const deviceUuid = await eda.lib_Device.create(
libraryUuid,
`嘉立创示例_修改前_${Date.now()}`,
[],
{ symbolType: 2 },
'修改前的描述'
);
// 2. 修改名称和描述(分类保持不变传 [])
const newName = `嘉立创示例_修改后_${Date.now()}`;
const modified = await eda.lib_Device.modify(deviceUuid, libraryUuid, newName, [], '修改后的描述');
// 3. 再补充修改扩展属性(位号、制造商)
await eda.lib_Device.modify(deviceUuid, libraryUuid, undefined, [], undefined, { designator: 'R', manufacturer: '嘉立创' });
// 修改类保留现场
console.log('deviceUuid:', deviceUuid);
console.log('modified:', modified);
console.log('newName:', newName);2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22