Hi, I have three sequential CGA scripts I would like to keep in separate files for simplicity. The second one uses "set" to define an attribute (BldgTypeCu) orginally defined in the main script, and then this attribute is used by the last script to set the color of the building. In theory, should work: however, I get an error message: 'No such attribute: BldgTypeCu in second script' (in essence). If I take the first call to the attribute out of the first script and leave it only in the second, it works, but then the third script does not seem to be able to access it. How do I fix this error? Here are the three scripts:the first:
version "2012.1"
attr ActualUseC = ""
attr BldgHeight = 0
attr BldgTypeCu = ""
attr Neighbourh = ""
attr ZoningCode = ""
attr NumberOfSt = ""
## to color by # of units
#attr Colorby = "NumberOfSt"
## OR to color by biulding use type
attr Colorby = "BldgTypeCu"
import bd1: "BuildingbyType.cga"(BldgTypeCu) #BldgTypeCu in parenthesis to allow imported script to over-ride attribute value in importing script
#import cr1 : "ColorRule.cga"
@StartRule
Footprint -->
case Neighbourh == "James Bay" || Neighbourh == "":
Building
else:
print("the neighborhood is: "+Neighbourh)
Building
color("#f0f0f0")
Building -->
bd1.Building
The second:/**
* File: BuildingbyType.cga
* Created: 22 Nov 2013 19:02:58 GMT
* Author: tfrappe
*/
version "2012.1"
attr ActualUseC = ""
attr ZoningCode = ""
attr BldgTypeCu = ""
import cr1 : "ColorRule.cga"
Building -->
## SFD
case ActualUseC == "000" || ActualUseC == "002" ||ActualUseC == "020" || ActualUseC == "032" || ActualUseC == "033"|| ActualUseC == "034"|| ActualUseC == "035"|| ActualUseC == "036" || ActualUseC =="041" || ActualUseC == "239":
set(BldgTypeCu,"SFD")
extrude(rand(6,8))
ColorRule
## LMFD
case ActualUseC == "029" || ActualUseC == "030" || ActualUseC == "039" || ActualUseC == "042" || ActualUseC == "047" || ActualUseC == "049" || ActualUseC == "050" || ActualUseC == "051" || ActualUseC == "052" || ActualUseC == "053" || ActualUseC == "057" || ActualUseC == "058" || ActualUseC == "237" || ActualUseC == "287"|| ActualUseC == "285" || ActualUseC == "286" :
set(BldgTypeCu,"LMFD")
extrude(rand(9,12))
ColorRule
else:
set(BldgTypeCu,"OTHER")
print("the actual use code is : "+ActualUseC)
extrude(25)
ColorRule
ColorRule -->
cr1.Color
The third:/**
* File: ColorRule.cga
* Created: 22 Nov 2013 18:54:39 GMT
* Author: tfrappe
*/
version "2012.1"
attr Colorby = ""
attr BldgTypeCu =""
attr NumberOfSt = ""
Color-->
case Colorby == "BldgTypeCu":
case BldgTypeCu == "SFD": color("#FFEBAF")
case BldgTypeCu == "SFD2": color("##F4C362")
case BldgTypeCu == "LMFD": color("#F4C362")
case BldgTypeCu == "HMFD": color("#FFAA00")
case BldgTypeCu == "COMM": color("#FF7F7F")
case BldgTypeCu == "IND": color("#704489")
case BldgTypeCu == "INST": color("#6788CA")
case BldgTypeCu == "MU": color("#FF7F7F") #SAME AS COMMERCIAL FOR NOW
case BldgTypeCu == "CMTY": color("#AB0066")
else: color("#00ffff")
else: color("#0000ff")