Working with the CGA Editor

The CityEngine includes a powerful editor for the creation and editing of CGA rules. Whenever a rule file (rule files have the extension *.cga) is opened, it is opened in the CGA editor.

Rule Errors and Warnings

CGA Editor - Error
The CGA Editor (top) and the Problems view (bottom). Note the highlighed error (red) on line 195.

In the picture above, a rule file is open in the CGA Editor; there is a syntax error in the CGA code (line 195: "->" instead of "-->"). The problem is detected automatically and marked red. Note: the position of errors are indicated as small red boxes next to the scrollbar on the right. More detailed information about the error can be found in the Problems view or by hovering the mouse cursor over the red error icon on the left:

CGA Editor - Error Tooltip

Errors need to be resolved before applying the rules. It is not possible to generate models if the assigned rule file contains errors.

The CGA Editor also issues warnings:

CGA Editor - Warning
Warnings are highlighted in yellow.

In this case, the rule WallsDone is not defined. This is not necessarily a problem. Warnings just indicate potential problems and do not prevent generation.

If your Problems View looks different you might need to configure it.

Code Completion

The CGA Editor features automatic code completion. At any position in the CGA code, you can press <ctrl + space> and a window pops up with a number of suggestions which match the current context. Use the cursor keys or the mouse to choose one.

CGA Editor - Code Completion
The code completion feature of the CGA Editor: On hitting <ctrl + space>, a number of suggestions matching the current context are presented.

Important Shortcuts

Very important shortcuts for working with the CGA Editor include:

Note: these shortcuts only work if the cga editor is the current view (i.e. its tab is highlighted). They might have different meanings in different views!

Problems View

On top of Rule Errors (static compile errors), the Problems View also shows Model Errors (dynamic runtime errors), i.e. problems encountered during generation of a model. Such errors / warnings depend on the rule as well as on the initial shape (i.e. its geometry and attributes such as the seed etc.). The Problems view is a great aid in finding and resolving such problems. In the example below a number of buildings were generated and two "asset not found warnings" were reported.

Problems View
Model Errors are reported during model generation.

To find the according model/shape, double-click on the warning and the model plus shape will be selected and framed. The picture below shows the inital shape and the generated model for whom the generation resulted in the "Could not load asset cube_bevel1_side.obj - file not found." warning.

Problems View
Double-clicking a Model Error selects and zooms to the culprit model. Note that the "isolate selection" button was used to hide all other models.


The Problems View can be configured according to your taste and needs. Here are the settings recommended by the CGA core grinders: