Solved! Go to Solution.
//Create some attributes to store data attr BUILDING_H = 0.0 attr HEIGHT = 0.0 MyRule--> //within a rule: set the Height attr to the value of BUILDING_H, //assuming BUILDING_H is mapped to a map layer set(HEIGHT, BUILDING_H) //use a value of an attr, in this case HEIGHT that was just set above extrude(world.y, HEIGHT) //attribute to store number of floors attr numberOfFloors=0 //numFloors is a Function, with the value BH passed to it //case statements work as if/elif/else statements, //else can be used to catch in this case a building height of 0, //since we only calculate if a building height is over 0, //if the building height is over 120(units) we divide by 4 instead of three.. if its over 0 but less than 120 we divide by 3 numFloors(BH) = case BH>120: floor(BH/4) case BH > 0: floor(BH/3) else: 0 MyRule --> //here we pass BUILDING_H to our Function numFloors //the value returned from the calculation is passed to the attribute numberOfFloors, //functions have funky syntax.. i know.. //attr numberOfFloors value can now be used elsewhere in the rule set (numberOfFloors, numFloors(BUILDING_H))
//Create some attributes to store data attr BUILDING_H = 0.0 attr HEIGHT = 0.0 MyRule--> //within a rule: set the Height attr to the value of BUILDING_H, //assuming BUILDING_H is mapped to a map layer set(HEIGHT, BUILDING_H) //use a value of an attr, in this case HEIGHT that was just set above extrude(world.y, HEIGHT) //attribute to store number of floors attr numberOfFloors=0 //numFloors is a Function, with the value BH passed to it //case statements work as if/elif/else statements, //else can be used to catch in this case a building height of 0, //since we only calculate if a building height is over 0, //if the building height is over 120(units) we divide by 4 instead of three.. if its over 0 but less than 120 we divide by 3 numFloors(BH) = case BH>120: floor(BH/4) case BH > 0: floor(BH/3) else: 0 MyRule --> //here we pass BUILDING_H to our Function numFloors //the value returned from the calculation is passed to the attribute numberOfFloors, //functions have funky syntax.. i know.. //attr numberOfFloors value can now be used elsewhere in the rule set (numberOfFloors, numFloors(BUILDING_H))
//Create some attributes to store data attr BUILDING_H = 0.0 attr HEIGHT = 0.0 MyRule--> //within a rule: set the Height attr to the value of BUILDING_H, //assuming BUILDING_H is mapped to a map layer set(HEIGHT, BUILDING_H) //use a value of an attr, in this case HEIGHT that was just set above extrude(world.y, HEIGHT) //attribute to store number of floors attr numberOfFloors=0 //numFloors is a Function, with the value BH passed to it //case statements work as if/elif/else statements, //else can be used to catch in this case a building height of 0, //since we only calculate if a building height is over 0, //if the building height is over 120(units) we divide by 4 instead of three.. if its over 0 but less than 120 we divide by 3 numFloors(BH) = case BH>120: floor(BH/4) case BH > 0: floor(BH/3) else: 0 MyRule --> //here we pass BUILDING_H to our Function numFloors //the value returned from the calculation is passed to the attribute numberOfFloors, //functions have funky syntax.. i know.. //attr numberOfFloors value can now be used elsewhere in the rule set (numberOfFloors, numFloors(BUILDING_H))
Does this help?
// This attr BUILDING_H = 0.0 attr HEIGHT = 0.0 @Startrule HeightSet--> set(HEIGHT, BUILDING_H) print(HEIGHT) Lot--> extrude(world.y,BUILDING_H)Mass attr NumberOfFloors = 0 numFloors(BH) = case BH>120: floor(BH/4) case BH > 0: floor(BH/3.5) else: 0 countFloors--> set (NumberOfFloors, numFloors(HEIGHT)) print(NumberOfFloors) // doesn't result in anyting...