[038] How to Select Street-Facing Faces with Comp() in CityEngine

Learn how to target street-facing faces using street selectors and handle streetWidth attributes in imported GIS data.

This tutorial explains how to use street selectors in CityEngine. They define front, back, and side faces relative to streets. We cover the essential requirement of the streetWidth attribute and how CityEngine handles geometry when these attributes are missing or imported from external CAD data.

In real-world GIS workflows, these selectors become especially important when working with imported parcel data.

CityEngine Street Selector Reference
img 1 : Visualization of street selectors. Source: Esri CGA Documentation
Street Selector Legend
img 2 : Definitions of front, back, left, and right relative to the street.

The face adjacent to the road is defined as 'front'. When looking at the shape from the road, the left side is 'left', the right side is 'right', and the back is 'back'. The combination of left and right is referred to as 'side'.

Mandatory Requirement: The streetWidth Attribute

A specific condition is required to use the street selector. As stated in the reference, the shape can be assigned the StreetWidth attribute. (We covered this in [014] How to Use First Edge & Street Edge Attributes in Esri CityEngine and [015-016] Compute First/Street Edges and Edge Attributes in Esri CityEngine)

Handling Blocks with Missing Attributes

In other words, if the block was not created using CityEngine's street creation tool, you must manually assign the street attributes. Let's look at how a block is created using the street creation tool.

CityEngine street creation tool.

Dynamic Parcel Generation Logic

The moment a closed polygon is formed, a parcel is created inside. Parcels are not created for open polygons.

The Lot generated in this manner automatically receives the streetWidth attribute, as shown in the figure below.

Automatic StreetWidth Attribute
img 3 : Automatically assigned streetWidth attributes on CityEngine lots.

The problem is that we rarely divide parcels in this exact way. Because these are parcels created by CityEngine's default algorithm, they are often difficult to apply directly in professional practice.

Even if you select the Block in the Inspector panel and change the Subdivision Type, the core limitation remains similar.

Changing Subdivision Types
img 4 : Selecting subdivision types in the Inspector panel.

You can see the differences by changing the area or other options.

Ultimately, roads and parcels should be created in CAD and then imported.

Let's compare two shapes as follows: Lot1 does not have the streetWidth attribute, and Lot2 has the streetWidth attribute.

Comparison Setup Lot1 vs Lot2
img 5 : Two lots prepared for testing selectors.

We will extrude them and apply each selector. The code is as follows:


Lot -->
    extrude(10) 
    color_comp

color_comp -->
    comp(f) { 
        street.front : color("#ff0000") | 
        street.back : color("#00ff00") | 
        street.left : color("#0000ff") | 
        street.right : color("#ffff00") | 
        street.side : color("#00ffff") | 
        all : color("#cccccc") 
    }

The result is...

Resulting Colors on Lots
img 6 : Result of applying street selectors to Lot1 and Lot2.

Both lots are colored, but the behavior differs. Lot1 does not have a streetWidth attribute. CityEngine treats its First Edge as street.front. Lot2 uses its assigned street attributes, so the result is correct.

Please remember: if the streetWidth attribute is missing, CityEngine treats the First Edge as street.front. Keep this in mind.


When drawing parcels in CAD, the starting point of a polygon may vary because road adjacency is not always considered during the drafting process.

If you import such data into CityEngine, you might find that unwanted faces are selected when choosing surfaces based on the road.

Therefore, when importing a large number of parcels, it is recommended to also import the road lines, select the parcels, perform 'Compute First/Street Edge', and then apply the selectors. In practice, skipping this step often leads to inconsistent facade selection, especially in large datasets. In practice, skipping this step often leads to inconsistent facade selection, especially in large datasets.

“Simplicity is the ultimate sophistication.”
— Leonardo da Vinci
Continue Learning
Explore complete tutorial collections for CityEngine and Global Mapper.

Comments

Popular posts from this blog

029] How to Split Polygon Areas with Intersecting Lines in Global Mapper

[008] How to Understand CGA Rule Structure in CityEngine (Beginner Guide)

046] How to Create Parallel Offset Lines in Global Mapper