# How can I display different densities in three levels with different colors?

Question asked by maziyaryousefi2016 on Dec 17, 2017
Latest reply on Apr 26, 2018 by maziyaryousefi2016

hello dear friends

•

• I wrote the rules for calculation the density

/**
* File: FAR.cga
* Created: 3 Dec 2017 17:57:03 GMT
* Author: mazyar
*/

version "2017.1"

@Group("Floor Num & Height",0) @order(0)
@Range(1,15)
attr FloorNum =rint(Height/3)

attr FloorHeight =3

attr Height =0

#####################################################
@Range(0,1)
attr Transparent =1

#####################################################

@Group("Building_Setback",3) @order(0)

@Range(0,10)
attr Front =5

@Range(0,10)
attr Back =3

@Range(0,10)
attr Side =2

@Hidden
attr ParcelArea =0

###################################################

@Group("FRA Reporting",3) @order(0)
@color
attr Low_FAR_Color ="#FF00FF"

@Group("FRA Reporting",3) @order(1)

@color
attr Medain_FAR_Color ="#00FF00"

@Group("FRA Reporting",3) @order(2)

@color
attr High_FAR_Color ="#0000FF"

##############################################

Lot -->
set(ParcelArea ,geometry.area())
report("LotArea" ,geometry.area())
setback(Front) { street.front : NIL | remainder :
setback(Back) { street.back : NIL | remainder :
setback(Side) { street.side : NIL | remainder :
Building
}
}
}

Building -->
extrude(FloorNum *FloorHeight)
split(y) { ~FloorHeight : Floors }*

Floors -->
case FAR > 0 && FAR <= 30 :color(Low_FAR_Color)set(material.opacity,0.4)
FARReporting
case FAR > 30 && FAR <= 60 :color(Medain_FAR_Color) set(material.opacity,0.4)
FARReporting
case FAR > 60 && FAR <= 100 :color( High_FAR_Color) set(material.opacity,0.4)
FARReporting
else :color(1,1,1)

FARReporting -->
report("FARBuilding" ,geometry.area(bottom)*FloorNum/ParcelArea)

FAR =geometry.area(bottom)*FloorNum/ParcelArea

/*ReportingBuilding -->
case FAR <= 0.30 :color(Low_FAR_Color)
set(material.specular.r,1)
set(material.specular.g,1)
set(material.specular.b,1)
set(material.opacity,Transparent)
set(material.reflectivity,0.5)
set(material.shininess,50)
case FAR > 0.30 && FAR <= 0.60 :color(Medain_FAR_Color)
set(material.specular.r,1)
set(material.specular.g,1)
set(material.specular.b,1)
set(material.opacity,Transparent)
set(material.reflectivity,0.5)
set(material.shininess,50)
case FAR > 0.6 && FAR <= 1 :color( High_FAR_Color)
set(material.specular.r,1)
set(material.specular.g,1)
set(material.specular.b,1)
set(material.opacity,Transparent)
set(material.reflectivity,0.5)
set(material.shininess,50)
else :color(1,1,1)

*/

• these are my rules for calculation the density

• now i want to classify densities in three modes of low density , moderate density (average) and high density

• so i can each floor is shown in a different color

• how do i do it?

• considering that the densities are in percent

• but in the conditional function i e case & else , the number can not be written as percent

• Floors -->
case FAR > 0 && FAR <= 30 :color(Low_FAR_Color)set(material.opacity,0.4)
FARReporting
case FAR > 30 && FAR <= 60 :color(Medain_FAR_Color) set(material.opacity,0.4)
FARReporting
case FAR > 60 && FAR <= 100 :color( High_FAR_Color) set(material.opacity,0.4)
FARReporting
else :color(1,1,1)

• I mean this part