getTreeKey function

Syntax

  • string getTreeKey()

Returns

The unique TreeKey of the shape being derived, formatted as a string list. The TreeKey is a list of integer numbers denoting the path from the root shape to the shape being derived in the shape tree. Each number denotes the 0-based child index, see example 1 below.

Note:

The TreeKey stays the same during derivation of the whole rule, see example 1 below.

Examples

Simple example

CGA code

Init-->
      print(getTreeKey() + " - Init") 
      center(xz)
      extrude(10)
      comp(f) { front: Facade}
	
Facade-->
      print(getTreeKey() + " - Facade")
      split(y) {'0.5 : Floor }*
	
Floor-->
      print(getTreeKey() + " - Floor")
      split(x) { '0.1 : Wall | '0.3 : Window 
                             | '0.1 : Wall }*
		
Wall-->
      print(getTreeKey() + " - Wall")

Window-->
      print(getTreeKey() + " - Window")

CGA console output

0; - Init
0;0; - Facade
0;0;0; - Floor
0;0;1; - Floor
0;0;0;0; - Wall
0;0;0;1; - Window
0;0;0;2; - Wall
0;0;0;3; - Wall
0;0;0;4; - Window
0;0;0;5; - Wall
0;0;1;0; - Wall
0;0;1;1; - Window
0;0;1;2; - Wall
0;0;1;3; - Wall
0;0;1;4; - Window
0;0;1;5; - Wall

Model Hierarchy

Model Hierarchy

The TreeKey stays the same during derivation of the whole rule

CGA code

ShapeA --> 
	print(getTreeKey) 
	split(x){ 2: ShapeB print(getTreeKey) 
         | 3: ShapeC print(getTreeKey) }

CGA console output

0;
0;
0;

In this topic
  1. Syntax
  2. Returns
  3. Examples