CGA styles

You can save a set of attribute values using styles. This allows you to save, manage, and retrieve favorite settings for a rule.

Create a style

To create a style, complete the following steps:

  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 window.
  3. Open the Default Style drop-down menu and click Add new Style.

    The Create and apply new style dialog box appears with the following options:

    Style name

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

    Based on

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

    Description

    Optionally, provide a description for the style.

  4. Click OK.
    • A new style is created and applied to the selected shape.
    • The new style is added to the .cga file.

Use the 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 on the Rule tab of the Inspector window.
  3. Select Preview & select styles.

    The Style Manager window 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 x to delete a style.

Toolbar options

The following options are available on the toolbar:

  • Tiles view or Scroll view—Display CGA styles as tiles or a list.
  • Without user attributes or 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, and 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 style.
  • Instead of using the wizard, you can also add and modify styles in the CGA Editor window. For more information, 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 value, which was set to 1.2 in the default style, is overwritten to 2.2 in the Facade_Wide style.

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

You can extend a style from an existing style. An extended style will inherit all definitions from its parent style. In the example above, the following are true:

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

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