Rule-based Modeling

In CityEngine, building models are described through CGA Rules. A CGA rule file consists of several rules that define how the actual building geometry is created. After a CGA rule file is assigned to a shape, the generation of the building model starting from this shape can begin. In this tutorial we will create a single CGA file with very basic rules.

Creating and writing a new rule file

A new CGA shape grammar rule file can be created by clicking:

A new CGA file is created in the rules/ directory of your project, and the CGA rule editor is opened.

In the CGA editor, grammar authoring can now be started by defining the building parameters: Therefore, the minimum and maximum building height are defined as so-called rule attributes. These values can later be changed conveniently for single buildings in the Inspector.

attr minheight = 10

attr maxheight = 30

Every shape (lot or street shape) has a specific start rule that triggers a rule from the rule file. For example, lots generated in the CityEngine have the start rule Lot by default. Select a single lot and look into the Inspector to see the current start rule.

Inspector view of a selected shape.

The Start Rule defines the first rule that is triggered form the rule set. We therefore write the start rule for our building as follows:

Lot --> extrude ( rand ( minheight, maxheight )) Envelope

The lot will be extruded to a random height between minheight and maxheight.

Note that pressing Ctrl-space in the CGA editor triggers the code completion feature. Possible commands and their parameters are listed as suggestions which makes coding CGA easier without the need to look up commands in the reference.

Assigning rules and generating

In the next step, the newly created rule file has to be assigned to the corresponding shapes (in the above case to lots):

The generated extruded models.

Copyright ©2008-2016 Esri R&D Center Zurich. All rights reserved.