CGA styles

You can save a set of attribute values using Styles. This helps you to save, manage and retrieve favourite settings for a given rule.

Create a new style

  1. Generate the following rule and select the model.

    @Color
    attr col = "#FF0000"
    attr height = 1
    
    Lot --> 
        color(col)
        extrude(height)

  2. Change the attribute values in the Inspector.
  3. Open the Default Style drop-down menu and click Add new Style.

    This opens the Create and apply new style dialog with the following options:

    Style name

    Use a unique name for your style. An existing style with the same name will be overwritten.

    Based on

    The reference style which the new style is based on. This can either be the Default Style or the current style (if one is applied).

    Description

    An optional description for the style.

  4. Click OK.
    • A new style has been created and it is applied to the selected shape.
    • The new style has been added to the CGA file.

Style manager

To apply a CGA style to shapes, do the following:

  1. Select a shape with a rule file assigned.
  2. Open the Style drop -down menu in the Rule Tab of the Inspector.
  3. Select Preview & select styles.....

    The Style Manager displays all available styles. A rule file that has no styles defined shows only one style (the default style).

  4. Click the style you want to assign to the selected shapes.
  5. Click OK (or double click the style).

Alternatively, click the red cross to delete a style.

Toolbar options

  • Tiles view/Scroll view: Display CGA styles as tiles or list.
  • Without user attributes/With user attributes: Optionally preserve user-set attributes on the shapes, overwriting the default style attributes.

Styles in CGA rule file

When a new style is created using the create style wizard, the active CGA rule file is modified, a new style section is created at the bottom of the rule file. Depending on the creation options, a different set of attributes is added to the new style.

  • A new style is created based on the default style: All user-set attributes are added as attributes to the new style, with their user value set as initial value (Default Rule value).
    style MyStyle
    attr col = "#006600"
    attr height = 2
  • A new style is created based on the current style: The new style extends the current one. Only attributes that are different from the base style are added as attributes to the new style, attributes from the base style are inherited.
    style MyStyle1 extends MyStyle
    attr col = "#99FF99"
Note:
  • When a new style is created based on an existing style, the new style extends the parent.
  • Instead of using the wizard styles can also be added and modified in the CGA Editor, see styles in the CGA reference.

Style keyword

# -- facade.cga
...
attr Window_Width = 1.2
attr Door_Height = 2.5

...
// all your Facade CGA rules
...

style Facade_Wide
attr Window_Width = 2.2
attr Door_Height = 2.8

By adding a new style using the style keyword and a style name, a new "namespace" is defined. All definitions below the style keyword are valid for this style only. In the example above the attr Window_Width, which was set to 1.2 in the Default Style is overwritten to 2.2 in the style Facade_Wide.

extends keyword

# -- facade.cga
...
attr Window_Width = 1.2
attr Door_Height = 2.5
...
// all your Facade CGA rules
style Facade_Wide
attr Window_Width = 2.2
attr Door_Height = 2.8

style Facade_Wide_2 extends Facade_Wide
attr Window_Width = 2.4

style Facade_Wide_3
attr Window_Width = 2.4

A style can be extended from an existing style. An extended style will inherit all definitions from its parent style. In the example above,

  • style Facade_Wide_2 inherits Door_Height from its parent Facade_Wide (value results in 2.8).
  • style Facade_Wide_3, which does not extend a parent, will inherit its value for Door_Height from the default style (resutling in 2.5).
Note:

All styles, if extended or not, implicitly extend the default style.