Unespected token error

129
1
09-11-2019 07:28 AM
Francesca_Nappo
New Contributor

I'm trying to color some land shapes according to their description (the attribute is called descriptiv), i'm really new to city engine and can't understand what it's wrong, but it keeps giving me an unespected token error. The code I'm using is

attr descriptiv = ""
@startrule
Colour-->                                    
color(descriptiv)=
case descriptiv == "building" :color(#8c5111)  #in this line I keep having "unespected token: case" and "unespected token: ="
case descriptiv == "general surface" :color(#2adbb2)
case descriptiv == "glasshouse" :color(#bae8e6)
case descriptiv == "Inland water" :color(#6ff1fc)
case descriptiv == "Inland water" :color(#6ff1fc)
case descriptiv == "landform" :color(#809c95)
case descriptiv == "natural environment" :color(#2c9171)
case descriptiv == "path" :color(#dec381)
case descriptiv == "rail" :color(#4a4948)
case descriptiv == "road or track" :color(#808080)
case descriptiv == "Roadside" :color(#adadad)
case descriptiv == "structure" :color(#ebebeb)
else :color(#ffffff)

0 Kudos
1 Reply
CherylLau
Esri Regular Contributor

First, remove line 11.  You can't define functions inside a rule (e.g. Colour --> ...this is the inside part of the rule that I mean), and you don't need to have a function here.  (Alternatively, though, you could specify a function that returns a hexadecimal string for the color, and then the rule would call the function inside color).

Second, the color operation takes in a string for a hexadecimal color, so you need to put the string inside quotation marks:

color("#ffffff")‍‍

color operation—CGA | ArcGIS 

Third, the start rule annotation should have some capital letters:  @StartRule

Annotations—CGA | ArcGIS 

0 Kudos