[036] CityEngine comp(): Selecting Sloped Faces with Horizontal, Vertical, Aslant, and Nutant

Learn to target specific building surfaces based on their angle and orientation using sloped-based comp selectors.

This tutorial explains how to use the horizontal, aslant, vertical, and nutant selectors in the comp() command. It provides a deep dive into how CityEngine classifies faces based on their normal angles relative to the local coordinate system and explains selector precedence when multiple selectors coexist within a single comp() rule.

First, take a look at the example below.

Initial sphere model for comp selector demonstration
img 1 : Sphere model used for selector testing

The following code demonstrates how to apply these selectors to the sphere shown above.

CGA Code Example and Visual Results

Lot1 --> primitiveSphere(10, 10, 10) Horizontal
Lot2 --> primitiveSphere(10, 10, 10) Aslant
Lot3 --> primitiveSphere(10, 10, 10) Vertical
Lot4 --> primitiveSphere(10, 10, 10) Nutant

Horizontal --> comp(f){horizontal : color(1,0,0) X.}
Aslant --> comp(f){aslant : color(1,0,0) X.}
Vertical --> comp(f){vertical : color(1,0,0) X.}
Nutant --> comp(f){nutant : color(1,0,0) X.}

And the results are as follows...

Visual results of sloped selectors
img 3 : comp() - horizontal, aslant, vertical, nutant visualized

As shown in the results, horizontal represents faces close to a flat plane, aslant represents faces tilted upwards, vertical represents faces close to vertical, and nutant represents faces tilted downwards (the opposite of aslant).

Technical Criteria and Angle Ranges

If we look at the official reference for these selectors:

Official ArcGIS CityEngine reference for comp selectors
Reference: Esri CityEngine CGA comp() Documentation

Horizontal Selector

First, you can see that these selectors use the local coordinate system, and faces are classified based on the angle between the face normal and the XZ plane of the base shape.

That angle logic is illustrated in the figure below.

Diagram explaining slope angle criteria
img 4 : Slope angle criteria for classification

As confirmed in the figure above, it refers to the angle between the normal direction of each face (represented by the sky blue arrow) and the XZ-plane of the shape.

Comparing Aslant, Nutant, and Other Selectors

Now, shall we compare selectors with similar ranges that we have learned so far?

Comparison of various face selectors
img 5 : Comparison of selectors like top, bottom, aslant, and nutant

You can immediately grasp the difference just by looking at the image above.

As a note, since the reference coordinate systems are different, a significant difference occurs when rotating the object, as shown below.

I explained this in the previous session as well.

 

CityEngine comp() Selector Rotation & Local Coordinates

You can choose and use selectors related to direction and slope as needed.

You can also mix and use them as shown below.


Lot1 --> primitiveSphere(10, 10, 10) Mix
Mix -->
    comp(f){
        aslant : color(1,0,0) X. |
        bottom : color(0,1,0) X. |
        world.west : color(0,0,1) X.
    }

Line 4 aslant : Sloped faces facing upwards in red,

Line 5 bottom : Bottom faces in green,

Line 6 world.west : West-facing faces in blue.


Let's look at the results.

Visual result of mixed selectors
img 7 : Visualizing mixed comp() selectors

We used various selectors utilizing both local and world coordinate systems.

Even when mixed like this, each maintains its respective reference coordinate system.

 

Video 2: Mixing Local and World Coordinate Selectors in CityEngine

Even when the object rotates, the world.west selector continues to highlight polygons facing West.

Selector Precedence and Execution Order in comp()

Now, here is one very important point...

Let's look at the following code.

Lot1 --> primitiveSphere(10, 10, 10) Mix1
Lot2 --> primitiveSphere(10, 10, 10) Mix2

Mix1 -->
    comp(f){
        aslant : color(1,0,0) X. |
        world.west : color(0,0,1) X. |
        bottom : color(0,1,0) X.
    }

Mix2 -->
    comp(f){
        aslant : color(1,0,0) X. |
        bottom : color(0,1,0) X. |
        world.west : color(0,0,1) X.
    }

The order of the selectors has changed.

In other words, the sequence of the "splitting" operation has been swapped.

For Lot1, world.west was defined before bottom, and for Lot2, bottom was defined first.

What kind of difference will this make?

First, let's look at the output.

Result comparison of swapped selector order
img 9 : Output comparison (Initial view)

The generated outputs appear identical initially.

Let's try rotating them to see what changes occur.

Video 3: CGA Rule Priority: Order of Operations in comp() Selectors

Can you spot the difference?

Yes. Priority is granted according to the split order.

In the case of Lot1, since world.west was processed before bottom, in regions where both conditions overlap, the world.west selector takes precedence. Therefore, parts of the bottom that face West change to blue.

In the case of Lot2, since bottom was processed before world.west, the world.west rule cannot "take over" the region already claimed by the bottom selector.

Among the selectors, there is all. This means "all elements."

Let's look at the next code.

Lot1 --> primitiveSphere(10, 10, 10) Mix1

Mix1 -->
    comp(f){
        all : color(1,0,0) X. |
        world.west : color(0,0,1) X. |
        bottom : color(0,1,0) X.
    }

In Line 5, the all selector takes first priority, followed by world.west and bottom.

What kind of result will come out?

Result showing 'all' selector dominance
img 11 : Everything is claimed by the 'all' selector

You can see that everything following is ignored, and all has claimed every face.

Literally, all means everything.

Let's look at the next example.

Lot1 --> primitiveSphere(10, 10, 10) Mix1

Mix1 -->
    comp(f){
        world.east : color(0,0,1) X. |
        all : color(1,0,0) X. |
        top : color(0,1,0) X.
    }

In this case, world.east takes first priority, followed by all and top.

You can probably guess the result by now.

Visual result of 'all' in second position
img 13 : world.east takes its area, 'all' takes the rest

world.east claimed its area first, and then all took everything else that remained.

Let's look at one final variation.

Lot1 --> primitiveSphere(10, 10, 10) Mix1

Mix1 -->
    comp(f){
        world.east : color(0,0,1) X. |
        top : color(0,1,0) X. |
        all : color(1,0,0) X.
    }

Here, world.east is first priority, top is second priority, and all is last.

The result:

Final result of complex priority selection
img 15 : Progressive selection based on rule order

world.west took its polygons first, then top claimed the top faces that weren't already taken by world.west, and finally, all claimed everything else.

This demonstrates how split order and selector priority work inside comp().

In the next session, we will explore eave | hip | valley | ridge, which are selectors used exclusively with the comp(e) command for edge components.

"People create boundaries and set limits for themselves. They define what is possible and impossible. Once we believe those limits, they become reality."
— Don Miguel Ruiz
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