A First Look at CGA Styles


PROBLEM: I've created a building with a ton of parameters set where I want them, and I want to keep this configuration so I can readily reproduce it.

SOLUTION: Styles. ESRI documentation says styles let you "quickly choose a set of predefined parameters" and are "a comfortable way to store and reuse sets of rule parameters".

For this exercise, you will need to copy and configure the three CGA files from the previous article.

The example is pretty simple. We have already created a cube shape with four faces and we have two sets of rules with parameters to individually color the front/back and left/right faces.  Using the controls we've created in the Shape Inspector, we can select the colors we want.

In the illustration above, we can see all of the three CGA rule files assigned to this shape: the main rule file ColorTheCubeMaster.cga plus two stand-alone rule files imported from a library into the master. There are hyperlinks to open each. When you mouse over the link to ColorTheCube_1 or _2, you will see a tooltip telling you it was imported via ColorTheCube_Master.cgb.   A CGB is a binary file, probably temporary, that cannot be opened. Your CGA file has not been altered.

  • Click on the cube, then select new colorFront and ColorBack values by clicking the color chip and selecting from the pop-up.
  • When you have what you want, click the drop-down to the right of the CGA file name and then Add New Style.
  • Enter a style name and a description, click OK.

Your style will appear as an option in the drop-down. SAVE THE CGA FILE because the change is being made there, Now click the link to the CGA file to open it. At the bottom, you will see this code:

@Description("An alternate style #1")
style AltStyle1
attr colorFront = "#00FF00"
attr colorBack = "#FF0000"

When creating a style from the Shape Inspector, modify the parameters BEFORE you Add New Style, or a style with no parameters will be created.  You cannot modify a style from the Shape Inspector; you will have to do it in the CGA code.

Go to the dropdown and click "Preview & Select Styles". This brings up the Style Manager, which will show you thumbnail images of each style.  You can apply a style by double-clicking. You can also delete styles from here.



Leave a Reply

Your email address will not be published. Required fields are marked *