import keyword


  • import id:filePath
  • import id( style-id_1, ... , style-id_n ):filePath
  • import id:filePath( attribute_1, ... , attribute_n )
  • import id:filePath( attribute_1 = value, ... , attribute_n = value )
  • import id:filePath()


  1. id

    Unique prefix for the imported rules, attributes and functions.

  2. filePath—string
    Absolute or relative path to a CGA rule file (e.g. "file.cga"). See Asset Search for details about the supported syntax.


Rules, attributes and functions from an existing rule file can be imported by a rule file through "import" (syntax 1). Importing a rule file makes all rules, attributes and functions of the imported rule file available prefixed by "id". If the imported rule file contains multiple styles (syntax 2) , by default all styles are imported and visible in the style manager. In order to limit the styles available in an importing rule file, the set of imported styles can be specified by enumerating the imported styles in parenthesis after the import id as in the second form of the import statement with id (syntax 2).

By default, attribute values from an importing rule file (e.g. "height" in "main.cga" below) are propagated to the imported rule file (e.g. "height" in "structure.cga" takes its value from "height" in "main.cga" below). In order to disable this default behavior (e.g. because an attribute in an imported rule file has the same name but a different semantic and should therefore not be overwritten), the attributes in an imported rule file can be protected by enumerating them after the rule file (syntax 3). Attributes can not only be protected but an importing rule file can additionally specify a new value for the attribute by redefining an attribute with an expression (syntax 4) where the right hand side expression is evaluated in the scope of the importing rule file.

Using empty parantheses protects all imported attributes.

Setting the attribute source of an imported attribute in the inspector to something else than "Rule-defined value" will disable this behavior for that attribute completely and the value will be taken from the designated source instead.

Imports can be annotated to control their attribute presentation in the inspector. See Annotations.


Combining two facades with a structure

// -- facade1.cga

actualFloorHeight =
actualTileWidth   =
Facade -->
	setupUV(0, 8*actualTileWidth, 8*actualFloorHeight)
	set(material.colormap, "f1.tif")
// -- facade2.cga

actualFloorHeight =
actualTileWidth   =
Facade -->
	setupUV(0, 8*actualTileWidth, 8*actualFloorHeight)
	set(material.colormap, "f2.tif")
// -- structure.cga

// the attribute height will be overridden by the
// attribute height from "main.cga" if this rule
// file is included. Thus if this rule file is
// used standalone, the buildings will be of height
// 100, if this rule file is included by "main.cga",
// the buildings will be of height 200.
attr height = 100

Lot-->extrude(height) Mass

Mass-->comp(f){ side: Facade | top: Roof } 
// -- main.cga

// define an attribute "height", potentially
// overriding the same attribute in imported
// rule files.

attr height = 200

// import facades
import f1 : "facade1.cga"
import f2 : "facade2.cga"

// import structure
import st : "structure.cga"

 	// reference rule "Lot" in structure.cga

// define rule "Facade" for structure.cga
	// reference rule "Facade" in facade1.cga
	50%  : f1.Facade  
	// reference rule "Facade" in facade2.cga
	else : f2.Facade

In this topic