Parameters and attributes in cityengine and filter objects by Attributes

Source: Internet
Author: User
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:

  1. Default
  2. Object
  3. User
  4. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.