Cityengine data parameter type
Cityengine has four different types of parameters:
1. Block parameter ------------ applies to Blocks
2. streetparameters ---------- apply to graph segments
3. intersectionparameters -- apply to graph nodes
4. ruleparameters ------------ applies to the shapes allocated with rule
Data Parameter Data Source Type
You can specify different attribute data sources for these parameters. There are four attribute data sources:
- Default
- Object
- User
- Layer
1. Default Value refers to the default value of the parameter value, which is followed by a bracket marked as default
2. objectattribute value refers to the attribute value that comes with the object Attribute Table. This data source can be specified only when the object attribute contains the attribute with the same parameter name.
3. User value refers to the value after the user modifies the parameter value. For example, after modifying the default value, the user value becomes the user value (compared with the default value graph)
The value of sidemo-widthleft is re-input by the user, which is changed from the original default value to the user value.
4. layer value layer attribute values
Get and modify parameter values
We can use Python scripts to assign values to object parameters in batches. The assigned values can be user-specified fixed values or an attribute value corresponding to objects. Here we mainly use two functions:
Ce. setattribute ()
Ce. setattributesource ()
The method for obtaining a parameter of different types is different. The specific method is as follows:
|
Block Parameter |
/CE/block/Parameter |
|
Street Parameters |
/CE/street/Parameter |
|
Intersection Parameters |
/CE/crossing/Parameter |
|
Rule Parameters |
/CE/Rule/Parameter |
For example:
We first pass ce. setattribute (Block, "lotareamax", 3000) adds a lotareamax attribute to the selected object, assigns a value of 3000, and then passes ce. the setattribute (Block, "/CE/block/lotareamax", "object") Statement sets the data source of the lotareamax parameter value in the selected block to the value of the lotareamax value just added to the object.
Filters and selects Objects Based on Object property values.
Using the withname method in Python, you can filter and filter objects by Object Name.
For example:
Lot = Ce. getobjectsfrom (Ce. Scene, Ce. withname ("'yyx '"))
This statement selects objects named yyx in all scenarios.
However, in actual use, we want to filter data based on an attribute value of objects. The solution here is:
1,First, the CE. getattribute () method is used to obtain the attribute value of a certain field of the selected object.
2. Change the object name to the obtained field attribute value through Ce. setname ().
3. loop through step 1 and Step 2 until all selected objects change the name
Finally, the CE. withname () method is used for filtering based on the attribute value.
The reference code is as follows:
'''Created on 2013-1-31@author: yuyouxiang'''from scripting import *# get a CityEngine instancece = CE()sceneobjects = ce.getObjectsFrom(ce.scene)for object in sceneobjects: Newname = ce.getAttribute(object,"Type") ce.setName(object,Newname)selectedobject = ce.getObjectsFrom(ce.scene,ce.withName("'Tree'"))ce.setSelection(selectedobject)
Note: "type" indicates the field name, and "Tree" indicates the attribute value to be filtered.
Through the above script, we can select all the objects whose value is tree in the Type field.