Working with the CGA Editor

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).

In the picture above, a rule file is open in the CGA Editor; there is a syntax error in the CGA code. 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 indicators in the CGA editor.

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 NewRule 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

You can open the Problems View using Window → Show Problems . 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 and 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 an "asset not found" error was reported.

Problems View
Model Errors are reported during model generation.

To find the according model or shape, double-click on the error 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 "asset not found" error.

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.

Configuration

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

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