Home > SCH_PrimitiveCircle > modify
SCH_PrimitiveCircle.modify() 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.
Modify the circle
Signature
typescript
function modify(
primitiveId: string | ISCH_PrimitiveCircle,
property: {
centerX?: number;
centerY?: number;
radius?: number;
color?: string | null;
fillColor?: string | null;
lineWidth?: number | null;
lineType?: ESCH_PrimitiveLineType | null;
fillStyle?: ESCH_PrimitiveFillStyle | null;
},
): Promise<ISCH_PrimitiveCircle | undefined>;1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
Parameters
Parameter | Type | Description |
|---|---|---|
primitiveId | string | ISCH_PrimitiveCircle | Primitive ID |
property | { centerX?: number; centerY?: number; radius?: number; color?: string | null; fillColor?: string | null; lineWidth?: number | null; lineType?: ESCH_PrimitiveLineType | null; fillStyle?: ESCH_PrimitiveFillStyle | null } | Modify Parameter |
Returns
Promise<ISCH_PrimitiveCircle | undefined>
Circle primitive object
Example
javascript
// 1. 创建待修改的测试圆(随机坐标避免与画布已有圆重合)
const x = 2000 + Math.floor(Math.random() * 8000);
const y = 2000 + Math.floor(Math.random() * 8000);
const circle = await eda.sch_PrimitiveCircle.create(x, y, 100, '#FF0000', 'none', 6, 1);
const circleId = circle.getState_PrimitiveId();
// 2. 读取修改前的半径、线宽与填充样式
const beforeRadius = circle.getState_Radius();
const beforeWidth = circle.getState_LineWidth();
const beforeFillStyle = circle.getState_FillStyle();
// 3. 批量修改:半径 100 → 200、线宽 6 → 10、填充样式改为实心
await eda.sch_PrimitiveCircle.modify(circleId, { radius: 200, lineWidth: 10, fillStyle: 'Solid' });
// 4. modify 返回后需要重新 get() 才能读到画布上的最新值
const refreshed = await eda.sch_PrimitiveCircle.get(circleId);
// 5. 修改类保留现场,供观察修改结果
console.log('primitiveId:', circleId);
console.log('radius:', beforeRadius, '→', refreshed.getState_Radius());
console.log('lineWidth:', beforeWidth, '→', refreshed.getState_LineWidth());
console.log('fillStyle:', beforeFillStyle, '→', refreshed.getState_FillStyle());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