[051] Understanding the Concept of Scope in CityEngine CGA

This tutorial breaks down the fundamental logic of the 'Scope' in Esri CityEngine CGA. We explore its core characteristics as a virtual bounding box, explain why rotation is necessary for non-orthogonal designs, and introduce the specific alignment commands needed to snap coordinate systems to geometry.

There is still more work to be done, but I’ve found some breathing room during the review phase.

Starting today, we will cover the "Scope," a concept I have consistently mentioned while discussing CityEngine’s CGA programming.

For users coming from traditional 3D modeling, Scope is often the first major obstacle when learning CityEngine CGA.

In CityEngine, it is virtually impossible to create various forms without understanding the Scope.

It is also quite difficult to find places to learn this, even when searching for CityEngine-related courses, lectures, or tutorials.


What Is Scope in CityEngine CGA?

The most basic characteristics of the Scope are as follows:

Characteristics of the Scope Bounding Box

First, it is a virtual rectangular parallelepiped (bounding box) that completely encloses the model. As you might guess from the word "virtual," it is invisible to the eye.

Going a step further:

Limitations of Scope Translation and Scaling

While the Scope can rotate together with the shape, it does not behave like an independent helper box detached from the geometry. This stems from the characteristic that it is a virtual box that perfectly fits the model. Therefore, it cannot exist at a position outside the model, and the Scope is always tightly coupled to the geometry rather than behaving like a freely editable helper box.

If you understand these two points, your basic understanding of the Scope is complete.

All that remains is the method of how to rotate the scope for use.

This leads to a question:

Why Scope Rotation Matters in Procedural Modeling

"Why do we have to rotate it?"

Because our world is not made up only of right angles.

The fundamental reason is to control the model (splitting, adding height, moving, and resizing) from various angles.

Then another question arises:

"Can't we just use the rotateScope command we learned before?"

Problems with Using rotateScope Alone

Of course, you can. However, rotateScope only rotates the scope by the input value; it is difficult to align the scope precisely to a specific geometric direction.

Suppose we have a heptagon (7-sided polygon).

If you want to align the X-axis of the scope with the fourth segment of that heptagonal plane, using rotateScope would require manual calculations for every step. If you consider complex 3D volumes, the calculations become even more overwhelming.

Scope Alignment Commands in CityEngine

That is why commands were created to designate (or snap) the axis direction of the scope:

alignScopeToAxes — Sets the object's XYZ axes as the scope's axes.

alignScopeToGeometry — Selects one of the geometry's axes, faces, or edges to serve as the scope axis.

alignScopeToGeometryBBox — Sets the minimum-sized bounding box surrounding the geometry as the scope axis.

Each command provides separate selectors, allowing you to precisely choose which elements define the scope axes.

Of course, if there were a way to snap the scope directly by clicking the desired element on the screen, these commands might not be necessary. However, at present, scope axis snapping is only possible through coding.

Now, let's look at a diagram to better understand how the scope encloses the geometry.


@Angle
attr rotate = 0

Lot --> 
    rotateScope(0, rotate, 0) 
    color(1, 1, 0) 
    A.

The code above uses @Angle to allow the value to be changed via a slider bar.

Depending on the angle of the slider bar, the scope rotates around the Y-axis.

Video: Visualizing Scope rotation in CityEngine

As I have always mentioned, the Scope can be verified through the Model Hierarchy panel.

You know that the counter-clockwise direction of the first edge becomes the X-axis, right?

When you change the rotate value, you can see the scope rotating.

As the scope rotates, the range of the scope changes, but it never exceeds the outermost vertices of the geometry.

How Scope Rotation Affects the split() Command

Now, let's see how the split() command works together with the scope.


@Angle
attr rotate = 0

Lot --> 
    rotateScope(0, rotate, 0) 
    color(1, 1, 0) 
    A

A --> 
    split(x){~1 : X. | ~1 : X. | ~1 : X.}

Video: Interactive demonstration of split lines rotating with the scope

As the scope rotates, the direction of the split rotates along with it.

Using Scope Rotation for Parking Lot Modeling

One practical use case for this technique is procedural parking lot generation.

Parking lots are usually divided into right angles, parallel lines, or diagonal lines; by rotating the scope, you can draw appropriate parking lines.

It's not easy to write after taking a break for a while.

I will end it briefly for today.

Frequently Asked Questions About Scope in CityEngine

Why is Scope important in procedural modeling?

Most CGA operations work relative to the Scope coordinate system rather than global world coordinates. The direction of splits, scaling, extrusion, and transformations all depend on the current Scope orientation.

Can the Scope rotate independently?

Yes. Commands such as rotateScope(), alignScopeToAxes(), and alignScopeToGeometry() can rotate or reorient the Scope. This changes how subsequent procedural operations behave.

Does split() follow the Scope direction?

Yes. The split() operation always follows the current Scope axes. If the Scope rotates, the split direction rotates together with it.

Can Scope exist separately from geometry?

No. In CityEngine, the Scope is tightly coupled to the shape geometry and acts as its procedural coordinate container rather than as an independent helper object.

What is the difference between Scope and world coordinates?

World coordinates describe the global scene axes, while Scope defines a local coordinate system attached to each procedural shape. Most CGA operations are performed relative to the Scope rather than the global world axes.

“Eye contact stimulates the release of oxytocin, strengthening emotional bonds. When meeting someone for the first time, maintaining eye contact long enough for oxytocin to take effect is often a far better choice than offering a firm handshake.”
— Brian Hare & Vanessa Woods, Survival of the Friendliest

Procedural modeling is ultimately about understanding relationships and orientation — much like how humans intuitively respond to direction and focus.

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