Details on the Python scripting API regarding parameters and attributes.
Parameter types for different objects
To get or set parameters a special prefix is required, starting with /ce/, followed by the type and the parameter name:
Block Parameter | on blocks | /ce/block/PARAMETER, e.g. /ce/block/lotAreaMin |
Street Parameters | on graph segments | /ce/street/PARAMETER, e.g. /ce/street/streetWidth |
Intersection Parameters | on graph nodes | /ce/crossing/PARAMETER, e.g. /ce/street/minArcRadius |
Rule Parameters | on shapes with rulefile assigned | /ce/rule/PARAMETER, rule parameters defined as attrs in the rule file |
Note:
Available parameters for block, street and intersection are a fixed set (as shown in the inspector), whereas rule parameters are an open list, defined by the attributes defined in the rule file.
Setting a user parameter
Assuming a block is selected
>>> block = ce.getObjectsFrom(ce.selection)[0]
>>> ce.setAttribute(block,"/ce/block/shapeCreation", False)
>>> ce.setAttributeSource(block,"/ce/block/shapeCreation", "USER")
The internal user attribute /ce/block/shapeCreation is set to false on the selected block. By setting the source of this parameter to USER, the user attribute is now active for this parameter.
This changes the shapeCreation parameter on the selected block from True to False, (Disables the creation of lot shapes on the block).
Using an object attribute as source for a parameter
Assuming a block is selected
>>> block = ce.getObjectsFrom(ce.selection)[0]
>>> ce.setAttribute(block,"lotAreaMax", 3000)
adding a new object attribute to the selected block.
>>> ce.setAttributeSource(block,"/ce/block/lotAreaMax", "OBJECT")
Setting the source of the parameter lotAreaMax to OBJECT. This connects the existing object attribute with matching name to the parameter. The parameter lotAreaMax now uses the value from the object attribute.
Listing attributes
Attributes of objects can be queried with ce.getAttribute, ce.getAttributeList() and ce.getAttributeSource()
>>> block = ce.getObjectsFrom(ce.selection)[0]
>>> ce.getAttributeList(block)
['/ce/block/seed', '/ce/block/shapeCreation', 'lotAreaMax']
Listing /ce/block/seed (user attribute), /ce/block/shapeCreation (user attribute), lotAreaMax (object attribute)
Note:
The list of internal attributes depends on the type of object queried, as well as previous user interaction on the object.
>>> ce.getAttribute(block,"lotAreaMax")
3000.0
The value of the object attribute lotAreaMax
>>> ce.getAttributeSource(block,"/ce/block/lotAreaMax")
OBJECT
The source of the parameter /ce/block/lotAreaMax
>>> ce.getAttribute(block,"/ce/block/shapeCreation")
0
The value of the user attribute /ce/block/shapeCreation
>>> ce.getAttributeSource(block,"/ce/block/shapeCreation")
USER
The source of the parameter /ce/block/shapeCreation