Home > IPCB_PrimitiveRegion > setState_RegionName
IPCB_PrimitiveRegion.setState_RegionName() 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.
Set the property state: region name
Signature
typescript
function setState_RegionName(regionName?: string): IPCB_PrimitiveRegion;1
Parameters
Parameter | Type | Description |
|---|---|---|
regionName | string | (Optional) Region name |
Returns
Region primitive object
Remarks
Only valid when ruleType is EPCB_PrimitiveRegionRuleType.FOLLOW_REGION_RULE, used to match region DRC rules
If ruleType is EPCB_PrimitiveRegionRuleType.FOLLOW_REGION_RULE but regionName is empty, the system will automatically assign a name
Example
javascript
// 1. 生成本次运行专用的坐标,避免与之前保留的测试图元重合
const x = 2000 + Math.floor(Math.random() * 100000);
const y = 2000 + Math.floor(Math.random() * 100000);
// 2. 创建一个带名称的约束区域(ruleType=9 即 FOLLOW_REGION_RULE)
const polygon = eda.pcb_MathPolygon.createPolygon(['R', x, y, 500, 300, 0, 0]);
const region = await eda.pcb_PrimitiveRegion.create(1, polygon, [9], '嘉立创示例_旧区域名');
const before = region.getState_RegionName();
// 3. 异步模式修改区域名称
const asyncRegion = region.toAsync();
asyncRegion.setState_RegionName('嘉立创示例_电源约束区');
await asyncRegion.done();
// 4. 从图元对象读回新值(保留现场供观察)
// 注:当前版本名称修改画布侧不落(重新 get() 仍是旧名),修改在图元对象上生效
const after = region.getState_RegionName();
console.log('regionName:', before, '→', after);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19