Home > SCH_PrimitiveComponent > createCbbSymbol
SCH_PrimitiveComponent.createCbbSymbol() method
此 API 当前处于 BETA 预览状态,希望得到开发者的反馈。它的任何功能都可能在接下来的开发进程中被修改,请不要将它用于任何正式环境。
创建复用模块符号
签名
typescript
function createCbbSymbol(
cbbSymbol: { libraryUuid: string; cbbUuid: string; uuid?: undefined | string },
x: number,
y: number,
rotation?: number,
mirror?: boolean,
): Promise<ISCH_PrimitiveCbbSymbolComponent | undefined>;1
2
3
4
5
6
7
2
3
4
5
6
7
参数名
参数 | 类型 | 描述 |
|---|---|---|
cbbSymbol | { libraryUuid: string; cbbUuid: string; uuid?: undefined | string } | 关联库复用模块符号, |
x | number | 坐标 X |
y | number | 坐标 Y |
rotation | number | (可选) 旋转角度 |
mirror | boolean | (可选) 是否镜像 |
返回值
Promise<ISCH_PrimitiveCbbSymbolComponent | undefined>
复用模块符号图元对象
示例
javascript
// 1. 从系统库搜索可用的复用模块
const cbbList = await eda.lib_Cbb.search('');
const cbb = cbbList[0];
// 2. 随机坐标避免与画布已有图元重合(SCH 坐标单位 10mil)
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
// 3. 创建复用模块符号(cbbUuid 传模块工程 UUID,符号 uuid 可省略由模块默认提供)
const symbol = await eda.sch_PrimitiveComponent.createCbbSymbol(
{
libraryUuid: cbb.libraryUuid, // CBB 工程所在库的 UUID
cbbUuid: cbb.uuid // CBB 工程的 UUID
},
x, // 坐标 X
y, // 坐标 Y
0, // 旋转角度
false // 是否镜像
);
// 4. 创建类保留现场,供在画布上观察模块符号
console.log('primitiveId:', symbol.getState_PrimitiveId());
console.log('primitiveType:', symbol.getState_PrimitiveType());
console.log('position:', symbol.getState_X(), ',', symbol.getState_Y());1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24