AnsweredAssumed Answered

Dynamic case?

Question asked by raze on Jan 7, 2015
Latest reply on Jan 8, 2015 by Holisticbynature

I'm generating some buildings (well, building envelopes) with variable floor counts (attribute "aog") and color for each of the floors. Right now I simply have the maximum number of floors inserted manually and catch the top with "aog-1". Is there a way to do this in a more flexible way?

 

Here's the rule file:

 

version "2014.0"


attr aog = 0
attr maxLength = scope.sx
attr maxWidth = scope.sz
attr maxHeight = 3.0*aog
attr opacityslider = 0.8


#--------------------------------


Lot -->
  set(material.opacity,opacityslider)
  innerRect
  s(maxLength+1,'1,maxWidth+1)
  center(xyz)
  extrude(maxHeight)
  Building

Building -->
  comp(f){side: BuildingBody | top: Roof }


BuildingBody -->
  split(y){ maxHeight/aog: BuildingFloors }*


BuildingFloors -->
  comp(f){all: ColorMe(split.index)}



ColorMe(FloorIndex) -->
  case FloorIndex == aog-1: color(0,1,1)
  case FloorIndex == 0: color(1,0,0)
  case FloorIndex == 1: color(0,1,0)
  case FloorIndex == 2: color(0,0,1)
  case FloorIndex == 3: color(1,1,0)
  case FloorIndex == 4: color(1,0,0)
  case FloorIndex == 5: color(0,1,0)
  case FloorIndex == 6: color(0,0,1)
  case FloorIndex == 7: color(1,1,0)
  case FloorIndex == 8: color(1,0,0)
  case FloorIndex == 9: color(0,1,0)
  case FloorIndex == 10: color(0,0,1)
  case FloorIndex == 11: color(1,1,0)
  else: color(0.5,0,0)



Roof -->
  color(1,1,1)
  roofGable(35,0,0,false)

 

Example:

colormeeee.png

Outcomes