Conditional Rules

702
6
Jump to solution
08-12-2012 07:26 PM
JoanneO_Brien
Occasional Contributor
Is it possible and if so how can you create a case function which would say something like:

attr steps = "#FFFFFF"  //have shown this as colour but actually want to have steps as a  //recursion extruding away from the BaseSide if possible.  BaseVolume -->      comp(f) {side : BaseSide(comp.index) | bottom : NIL | top : extrude(height - Roof_Height) Mass }    BaseSide (myIndex) --> case myIndex == 3 && scope.sx >= 1.5:                                       split(x) {~1: color(grey) | 1.5 : color(steps) | ~1 color(grey)}                else : color(grey)


This currently isn't working but would love it to! I've attached a screenshot of one of my doors, although of course every building which has a BaseSide would have different heights below the door hence I'd love to work out using the recursion rule here too since then it could decide how many steps are needed.

I've also been trying to work out if there is a better way of assigning where the door goes but at the moment all I can come up with is telling it to put the door on wall number three, where ever that might be.

Ultimately it'd be so nice to be able to select a wall manually and then say right I'd like to use this code on this wall but that code on the others but I don't believe this is possible...
0 Kudos
1 Solution

Accepted Solutions
MatthiasBuehler1
Frequent Contributor II
hey !

I did not get your point of the recursions. what would they be for in your case ?

btw. you can make an attr for your index. that way you can use a slider to choose the wall index interactively.

* * *

I've taken some time to code your thing very simply :

check the code very precisely and try to find out what it does.

- check out the case blocks and what is tested after each other.
- check how door placement variation is done
- check how I managed the stepping

let me know if you have more questions !

Matt


@Group ("Building Main") attr buildingHeight = 5 @Group ("Building Main") @Range(1, 20) attr wallID = 3 @Group ("Building Main") attr baseHeight = 0.8  Lot -->  extrude(world.y, buildingHeight)  comp(f) { side =  Facades | top : Roof.} # note the # which puts all sides in 1 shape !  Facades -->  comp(f) {wallID : DoorFacade | all : WallWithWindows}  minWallWidth = 0.3 # don't make an attr to keep the variation !  @Group ("Doors") attr doorWidth = 1 @Group ("Doors") attr doorHeight = 2.0  DoorFacade -->  case scope.sx < doorWidth + 2 * minWallWidth :   Wall  else :  33%:   # door centered    split(x) { ~1 : WallWithWindows | doorWidth : DoorPart | ~1 :WallWithWindows}   33%:   # door left    split(x) { minWallWidth : WallWithWindows | doorWidth : DoorPart | ~1 :WallWithWindows}   else :   # door right    split(x) { ~1 : WallWithWindows | doorWidth : DoorPart | minWallWidth  :WallWithWindows}     @Group ("Windows") attr windowBaseHeight = 0.8 @Group ("Windows") attr windowHeight = 1.2 @Group ("Windows") attr windowWidth = 1.0  windowDist = rand(.5,2) # don't make an attr to keep the variation !  WallWithWindows -->  case scope.sx <= minWallWidth :   Wall  else :   split(y) {windowBaseHeight + baseHeight : Wall | windowHeight : WindowArea | ~1 : Wall}     WindowArea -->  split(x) {{~windowDist : Wall | windowWidth : Window}* | ~windowDist : Wall}  Window -->  color(.3,.3,.4)     DoorPart -->  split(y) {baseHeight : Base | doorHeight : Door | ~1 : Wall}  Door -->  color(.3,.2,.2)     @Group ("Steps") attr stepHeight = 0.19 @Group ("Steps") attr stepDepth = 0.27  Base -->  split(y) {~stepHeight : Step(split.total - split.index)}*  Step(index) -->  extrude(stepDepth * index)      Wall -->  color(.8,.7,.7)    

View solution in original post

0 Kudos
6 Replies
LechKar_owicz
New Contributor II
Ultimately it'd be so nice to be able to select a wall manually and then say right I'd like to use this code on this wall but that code on the others but I don't believe this is possible...


This was what I was thinking (btw. that was the intention of starting this topic. If you could pass a path to fasade-specific rule file as a building attribute and if you could also pass the index of the wall to use the rule as an other attribute then it would be it. The base rule file would need to be a bit compilcated but I don't see any other way. And so far I haven't been able to do it this way...
0 Kudos
MatthiasBuehler1
Frequent Contributor II
hey !

I did not get your point of the recursions. what would they be for in your case ?

btw. you can make an attr for your index. that way you can use a slider to choose the wall index interactively.

* * *

I've taken some time to code your thing very simply :

check the code very precisely and try to find out what it does.

- check out the case blocks and what is tested after each other.
- check how door placement variation is done
- check how I managed the stepping

let me know if you have more questions !

Matt


@Group ("Building Main") attr buildingHeight = 5 @Group ("Building Main") @Range(1, 20) attr wallID = 3 @Group ("Building Main") attr baseHeight = 0.8  Lot -->  extrude(world.y, buildingHeight)  comp(f) { side =  Facades | top : Roof.} # note the # which puts all sides in 1 shape !  Facades -->  comp(f) {wallID : DoorFacade | all : WallWithWindows}  minWallWidth = 0.3 # don't make an attr to keep the variation !  @Group ("Doors") attr doorWidth = 1 @Group ("Doors") attr doorHeight = 2.0  DoorFacade -->  case scope.sx < doorWidth + 2 * minWallWidth :   Wall  else :  33%:   # door centered    split(x) { ~1 : WallWithWindows | doorWidth : DoorPart | ~1 :WallWithWindows}   33%:   # door left    split(x) { minWallWidth : WallWithWindows | doorWidth : DoorPart | ~1 :WallWithWindows}   else :   # door right    split(x) { ~1 : WallWithWindows | doorWidth : DoorPart | minWallWidth  :WallWithWindows}     @Group ("Windows") attr windowBaseHeight = 0.8 @Group ("Windows") attr windowHeight = 1.2 @Group ("Windows") attr windowWidth = 1.0  windowDist = rand(.5,2) # don't make an attr to keep the variation !  WallWithWindows -->  case scope.sx <= minWallWidth :   Wall  else :   split(y) {windowBaseHeight + baseHeight : Wall | windowHeight : WindowArea | ~1 : Wall}     WindowArea -->  split(x) {{~windowDist : Wall | windowWidth : Window}* | ~windowDist : Wall}  Window -->  color(.3,.3,.4)     DoorPart -->  split(y) {baseHeight : Base | doorHeight : Door | ~1 : Wall}  Door -->  color(.3,.2,.2)     @Group ("Steps") attr stepHeight = 0.19 @Group ("Steps") attr stepDepth = 0.27  Base -->  split(y) {~stepHeight : Step(split.total - split.index)}*  Step(index) -->  extrude(stepDepth * index)      Wall -->  color(.8,.7,.7)    
0 Kudos
JoanneO_Brien
Occasional Contributor
Hi

Thanks for that I modified it beautifully to insert it into my model so it works well! I'd been thinking that maybe a recursion could be used to generate steps depending on height but your method works much better! :) :)
0 Kudos
MatthiasBuehler1
Frequent Contributor II
cool !

show us some pictures once your done .. or even WIP ! :)
0 Kudos
JoanneO_Brien
Occasional Contributor
So I am getting some beautiful stairs, unfortunately there still seems to be one slight problem as shown in the image, when I am generating a model on a hill, some sides have a base below them and some don't. This results in the sides having different numbers so that when I do a case(myIndex) to get stairs forming on sides with doors, it doesn't count the sides which don't have a base and so my stairs end up on different places to my doors! Do you know a way to fix this?
0 Kudos
MatthiasBuehler1
Frequent Contributor II
hi !

yes, there is a solution to this, though you may need to rewrite a little of the code.

as you may know, 'const' values are evaluated only once per shape, then remain so during the model generation process.

e.g. :
const doorSide = 33% : "left" 33%: "right" else : "center"


so in the code which places the split where the DoorTile is created ( with the 3 random placements left, right, middle), you could add the code line above as a new const and then change the code to :
case doorSide == "left" : split()
..

instead of :
33% : split() left
..


that way, the const drives the door position. ( you could also make an attr out of it and set it manually. let me know if you wanna know how. that's easy to do.)

* * *

now the second issue is to synch that the stairs get constructed at the same position as the door. for that, you can use the same splits as for the door and the same case structure which obeys the doorSide const too. That way, you can guarantee that the stairs get created below the doors.

I'm not perfectly sure how the indices are defined to set the actual wall for the stairs. would have to look at this.

let me know if you need help on this.
0 Kudos