Home > SCH_PrimitiveComponent > createCbbSymbol
SCH_PrimitiveComponent.createCbbSymbol() 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.
Create Reuse block symbol
Signature
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
Parameters
Parameter | Type | Description |
|---|---|---|
cbbSymbol | { libraryUuid: string; cbbUuid: string; uuid?: undefined | string } | Associated library reuse block symbol. |
x | number | X coordinate |
y | number | Y coordinate |
rotation | number | (Optional) Rotation angle |
mirror | boolean | (Optional) Whether it is mirrored |
Returns
Promise<ISCH_PrimitiveCbbSymbolComponent | undefined>
Reuse block symbol primitive object
Example
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