参数和属性

有关参数和属性的 Python 脚本 API 详细信息。

不同对象的参数类型

要获取或设置参数,需要一个以 /ce/ 开头,后跟类型和参数名称的特殊前缀:

区块参数

面向区块

/ce/block/PARAMETER, 例如 /ce/block/lotAreaMin

街道参数

面向图表段

/ce/street/PARAMETER, 例如 /ce/street/streetWidth

交叉点参数

面向图形节点

/ce/crossing/PARAMETER, 例如 /ce/street/minArcRadius

规则参数

面向已分配规则文件的形状

/ce/rule/PARAMETER,定义为规则文件中属性的规则参数

注:

区块、街道和交叉路口的可用参数为固定集(如检查器中所示),而规则参数则是一个由规则文件中定义的属性定义的开放列表。

设置用户参数

假定已选择了一个区块

>>> block = ce.getObjectsFrom(ce.selection)[0]
>>> ce.setAttribute(block,"/ce/block/shapeCreation", False)
>>> ce.setAttributeSource(block,"/ce/block/shapeCreation", "USER")

内部用户属性 /ce/block/shapeCreation 已设置为所选区块上的 false。 在将此参数的源设置为 USER 后,现在该参数的用户属性已处于活动状态。

这会使所选区块的 shapeCreation 参数由 True 更改为 False(禁用在区块上创建地块形状)。

使用对象属性作为参数的源

假定已选择了一个区块

>>> block = ce.getObjectsFrom(ce.selection)[0]
>>> ce.setAttribute(block,"lotAreaMax", 3000)

将新对象属性添加到所选区块。

>>> ce.setAttributeSource(block,"/ce/block/lotAreaMax", "OBJECT")

将参数 lotAreaMax 的源设置为 OBJECT。 该操作会将具有匹配名称的现有对象属性连接到该参数。 现在,参数 lotAreaMax 将使用来自对象属性的值。

列出属性

可以使用 ce.getAttributece.getAttributeList()ce.getAttributeSource() 来查询对象的属性

>>> block = ce.getObjectsFrom(ce.selection)[0]
>>> ce.getAttributeList(block)
['/ce/block/seed', '/ce/block/shapeCreation', 'lotAreaMax']

列出 /ce/block/seed(用户属性)、/ce/block/shapeCreation(用户属性)、lotAreaMax(对象属性)

注:

内部属性的列表取决于所查询对象的类型以及该对象先前的用户交互。

>>> ce.getAttribute(block,"lotAreaMax")
3000.0

对象属性 lotAreaMax 的值

>>> ce.getAttributeSource(block,"/ce/block/lotAreaMax")
OBJECT

参数 /ce/block/lotAreaMax 的源

>>> ce.getAttribute(block,"/ce/block/shapeCreation")
0

用户属性 /ce/block/shapeCreation 的值

>>> ce.getAttributeSource(block,"/ce/block/shapeCreation")
USER

参数 /ce/block/shapeCreation 的源