CGA Editor

In the CGA Editor, you can write, modify, and save CGA rules. To edit a CGA rule, do the following:

  1. Open the CGA rule file.
    • Double click the rule file in the Navigator.
    • Click Rule File in the Inspector if the selected object has a rule file assigned to it.
  2. Make necessary edits.
  3. Press Ctrl+S to save the CGA rule file or use File > Save from the menu.
Note:
  • The CGA Editor has syntax highlighting for better readability of the code.
  • The CGA Editor detects syntax errors and highlights them white a white cross on red background. Click Window > Show Problems in the main menu for a list of syntax errors.
  • Press Ctrl + Space when typing to complete a command.

Manage rule errors and warnings

Rule file with syntax error
Rule file with syntax error

The syntax error in the CGA code 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 over the red indicators or error markers 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:

Rule file not defined
Rule file not defined warning

In this case, the rule NewRule is not defined. This is not necessarily a problem. Warnings indicate potential problems but still allow generation.

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.

Model error
Model error

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 initial shape and the generated model in which the generation resulted in the "asset not found" error.

Asset not found error
Asset not found error

Configuration

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

  • Right-click in the Problems View and select Broup By > Type to group the errors by their type (i.e. separate Rule Errors and Model Errors):
  • Click Location to sort the errors by Location (i.e. by their initial shape)
  • Right-click and select Configure Contents.
    • Deselect Use item limits to disable the default limit of 100 markers.

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.

Important shortcuts

Very important shortcuts for working with the CGA Editor include:

  • Ctrl+S—save the file (changes must be saved before generation; files with changes are marked with an asterix * in the tab)
  • Ctrl+G—generate (the selected objects, i.e. shapes or models)
  • Ctrl+F5—re-generate all models
  • Ctrl+F—opens "find / search-replace" dialog
  • Ctrl+L —opens "go to line" dialog
  • Ctrl+Shift+L—shows all shortcuts
Note:

These shortcuts only work if the CGA Editor is the current view (i.e. its tab is highlighted).