CGA reference

The Computer Generated Architecture (CGA) shape grammar of CityEngine is a unique programming language that you can specify to generate architectural 3D content. You can use grammar-based modeling to define rules, or CGA rules, within CityEngine that iteratively refine a design by creating more and more detail. CGA rules operate on shapes which consist of a geometry in a locally oriented bounding-box (the so-called scope). The following rule derivation illustrates the process: on the left side the start shape is shown and on the right side the resulting generated model is displayed.

CGA generation

Operations

Geometry creation

Geometry subdivision

Geometry manipulation

Texturing

Transformations

Scope

Flow control

Context

Attributes

Shape attributes

comp | initialShape | material | pivot | scope | seedian | split | trim

Built-in functions

Functions always return a value and do not alter the current shape (with the exception of probability functions which change the state of the shape's random number generator).

Math functions

abs | acos | asin | atan | atan2 | ceil | cos | exp | floor | isinf | isnan | ln | log10 | pow | rint | sin | sqrt | tan

Probability functions

p | rand

Conversion functions

bool | float | isNull | sel | str

String functions

count | find | len | splitString | substring

Geometry functions

geometry.angle |geometry.area | geometry.boundaryLength | geometry.{du|dv} | geometry.height | geometry.isClosedSurface | geometry.isConcave | geometry.isInstanced | geometry.isOriented | geometry.isPlanar | geometry.isRectangular | geometry.nEdges | geometry.nFaces | geometry.nHoles | geometry.nVertices | geometry.{uMin|uMax|vMin|vMax} | geometry.volume

File functions

fileExists | fileSearch | readTextFile

Asset and image functions

assetInfo | assetNamingInfo | assetsSortRatio | assetsSortSize | imageInfo | imagesSortRatio

Occlusion functions

inside | overlaps | touches

Context functions

contextCompare | contextCount | minimumDistance

Array functions

comp | index | item operator | size

Edge attribute functions

edgeAttr.getBool | edgeAttr.getFloat | edgeAttr.getString

Miscellaneous functions

convert | getGeoCoord | getTreeKey | print | Simple types of operators

Other keywords

attr | const | import | style | version

CGA utility functions library

String utility functions

findFirst | findLast | getPrefix | getRange | getSuffix | replace

String list utility functions

listAdd | listClean | listCount | listFirst | listIndex | listItem | listLast | listRandom | listRange | listRemove | listRemoveAll | listRetainAll | listSize | listTerminate

File, asset and image utility functions

assetApproxRatio | assetApproxSize | assetBestRatio | assetBestSize | AssetFitSize | fileBaseName | fileDirectory | fileExtension | fileName | fileRandom | imageApproxRatio | imageBestRatio

Match utility functions

clamp | min | max

Color utility functions

colorHexToB | colorHexToG | colorHexToH | colorHexToO | colorHexToR | colorHexToS | colorHexToV | colorHSVToHex | colorHSVOToHex | colorRamp | colorRGBToHex | colorRGBOToHex

Miscellaneous information

CGA changelog | Annotations | Asset search | Built-in assets | Context and occlusion queries | Euler angles | Texturing