In the CGA Editor, you can write, modify, and save CGA rules. To edit a CGA rule, do the following:
- 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.
- Make necessary edits.
- 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 with a white X on a red background. Click Window > Show Problems in the main menu for a list of syntax errors.
- Press Ctrl+Spacebar when typing to complete a command.
Manage rule errors and warnings
The syntax error in the CGA code is detected automatically and marked red.
Note:
The position of an error is indicated by a small red box 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 must 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:
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), in other words, problems encountered during generation of a model. Such errors and warnings depend on the rule as well as on the initial shape (in other words, its geometry and attributes such as the seed, and so on). The Problems view allows you to find and resolve such problems. In the example below, a number of buildings were generated and an "asset not found" error was returned.
To find the according model or shape, double-click 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.
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 Group By > Type to group the errors by their type (in other words, separate Rule Errors and Model Errors):
- Click Location to sort the errors by Location (in other words, 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+Spacebar and a pop-up appears with a suggestions that match the current context. Use the cursor keys or the mouse to choose one.
Keyboard shortcuts
Keyboard shortcuts for working with the CGA Editor include the following:
- Ctrl+S—Save the file (changes must be saved before generation; files with changes are marked with an asterisk (*) on the tab).
- Ctrl+G—Generate (the selected objects, in other words, shapes or models).
- Ctrl+F5—Re-generate all models.
- Ctrl+F—Opens the Find / search-replace dialog box.
- Ctrl+L —Opens the Go to line dialog box.
- Ctrl+Shift+L—Shows all shortcuts.
Note:
These shortcuts only work if the CGA Editor is the current view (in other words, its tab is highlighted).