Parametric Model


3DS Max, Rhinoceros, Rhinoscript, Scripting

Rhinoscripted a parametric model of the Centre Pompidou by Renzo Piano. Script generates a parametric building facade where the width, height and number of rooms on a floor were randomly generated. Script was run in Rhinoceros and the resulting models were rendered in 3DS Max.

renzo-sizes2

Rhinoscript Code

‘minimum is 6 meters (wide) by 4 meters (high)
‘6m = ~ 19.685’
‘4m = ~13.1234’

Option Explicit

Dim width_bldg, floors_bldg
Dim arrVector1, arrVector2
Dim rotataxis_y, rotataxis_x
Dim bar_mini, barpt, horizontal, horizontal2
Dim bldg_width, bldg_height, bldg_rooms, max_counter, bldg_floors
Dim room_width, room_height, room_depth
Dim bar_incline1, bar_incline2
Dim bar_horizontal, bar_horizontal2, bar_horizontal3
Dim incline_bar
Dim skinny_bars, fatter_bars
Dim counter_h
Dim counter
Dim counter_y ‘ # of floors
Dim counter_x ‘ # of rooms / floor
Dim slope,slope_f, theta, hyp, adj, new_hyp, runout_height, runout_width, odd_even, y_start, runout_height_lower
Dim diagonal_radius
Dim depth

room_depth = Rhino.GetReal(“Enter room depth”)
depth = 12

”Enter width of building
bldg_rooms = Rhino.GetReal(“Enter # rooms for each floor”)
bldg_rooms = Round (Rnd()*10)+1

”Enter number of floors
bldg_floors = Rhino.GetReal(“Enter # of floors”)
bldg_floors = Round (Rnd()*10)+1

room_depth = depth – 2

‘room_height = 4 ‘4m
‘room_width = 6 ‘6m
‘room_depth = 5 ’10m

skinny_bars = .08 ‘8 cm radius
fatter_bars = .12 ’12 cm radius

‘Slope
incline_bar = .6 ‘room_width / 7 * .5

max_counter = bldg_rooms – 1 ‘this is for # of big and small columns
bldg_width = bldg_rooms * room_width
bldg_height = bldg_floors * room_height
‘bldg_height = height
‘bldg_width = width
room_width = bldg_width / bldg_rooms
room_height = bldg_height / bldg_floors

‘3D vector for rotating about the x-axis
arrVector1 = Array(0,0,0)
arrVector2 = Array(1,0,0)
rotataxis_x = Rhino.VectorAdd(arrVector1, arrVector2)

‘3D vector for rotating about the y-axis
arrVector1 = Array(0,0,0)
arrVector2 = Array(0,1,0)
rotataxis_y = Rhino.VectorAdd(arrVector1, arrVector2)

”””””””””””””””””””””””””””””””””””
‘draw stairs that zig-zig across building, bottom left to upper right’
”””””””””””””””””””””””””””””””””””
‘If the building is more than two stories high, then create zig,zag stairs
‘starts at x=bldg_width, ends at x = 0
‘each stair segment is room_width WIDE x room_height HIGH

counter_x = bldg_rooms
counter_y = 0

Do While counter_x > 0
‘incline stair
Rhino.AddCylinder Array( counter_x*room_width, depth, counter_y*room_height), _
Array ((counter_x-1)*room_width, depth, (counter_y+1)*room_height), 1.5

If (counter_x-2 >= 0 And counter_y < bldg_floors) Then
‘Sphere
If (counter_x-2 = 0) Then
Rhino.AddSphere Array ((counter_x-1)*room_width, depth, (counter_y+1)*room_height), 1.5
Else
Rhino.AddSphere Array ((counter_x-1)*room_width, depth, (counter_y+1)*room_height), 1.5
Rhino.AddSphere Array ((counter_x-2)*room_width, depth, (counter_y+1)*room_height), 1.5
End If

‘horizontal stair
Rhino.AddCylinder Array ((counter_x-1)*room_width, depth, (counter_y+1)*room_height), _
Array ((counter_x-2)*room_width, depth, (counter_y+1)*room_height), 1.5
End If

counter_x = counter_x – 2
counter_y = counter_y + 1

Loop

””””””””””””””””
‘draw bars that criscross facade
””””””””””””””””’

hyp = Rhino.Hypot (room_width, 2*room_height)
slope = room_width/ hyp ‘reversed rise/run because value in ATanH needs to be between 0 and 1
theta = Rhino.ACos(slope)
new_hyp = (room_height * bldg_floors) / Sin(theta) ‘find the new hypotenuse
adj = new_hyp * Cos(theta)
diagonal_radius = .05

”right to left
counter = 0

Do While counter < bldg_rooms

If (adj+counter*room_width > bldg_width) Then
runout_width = bldg_width – counter*room_width
runout_height = bldg_height – (2*room_height / room_width)*runout_width
Rhino.AddCylinder Array(counter*room_width, room_depth, bldg_height), Array (bldg_width, room_depth, runout_height), diagonal_radius ”2cm diameter
Else
Rhino.AddCylinder Array(counter*room_width, room_depth, bldg_height), Array (adj+counter*room_width, room_depth, 0), diagonal_radius ”2cm diameter
End If
counter = counter + 1
Loop

”left to right
counter = bldg_rooms

Do While counter > 0

If (counter*room_width-adj < 0) Then
runout_width = counter*room_width
runout_height = bldg_height – (2*room_height / room_width)*runout_width
Rhino.AddCylinder Array(counter*room_width, room_depth, bldg_height), Array (0, room_depth, runout_height), diagonal_radius ”2cm diameter
Else
Rhino.AddCylinder Array(counter*room_width, room_depth, bldg_height), Array (counter*room_width-adj,room_depth, 0), diagonal_radius ”2cm diameter
End If
counter = counter – 1
Loop

”right to left (remaining)
If bldg_floors > 2 Then
counter = bldg_floors – 2

Do While counter > 0
new_hyp = (room_height * counter) / Sin(theta) ‘find the new hypotenuse
adj = new_hyp * Cos(theta)
runout_height = bldg_height – 2*room_height
runout_width = bldg_height/ (2*room_height / room_width)
runout_height_lower = counter*room_height – (2*room_height / room_width) * bldg_width

If (runout_height_lower > 0) Then
‘If (runout_width > bldg_width) Then
Rhino.AddCylinder Array(bldg_width, room_depth, runout_height_lower), Array (0, room_depth, counter*room_height), diagonal_radius ”2cm diameter
Else
Rhino.AddCylinder Array(0, room_depth, counter*room_height), Array (adj, room_depth, 0), diagonal_radius ”2cm diameter
End If
counter = counter – 2
Loop

End If

”left to right (remaining)

If bldg_floors > 2 Then
counter = bldg_floors – 2
Do While counter > 0

new_hyp = (room_height * counter) / Sin(theta) ‘find the new hypotenuse
adj = new_hyp * Cos(theta)
runout_height = bldg_height – 2*room_height
runout_width = bldg_height/ (2*room_height / room_width)
runout_height_lower = counter*room_height – (2*room_height / _
room_width) * bldg_width

If (runout_height_lower > 0) Then
Rhino.AddCylinder Array(bldg_width, room_depth, counter*room_height), _
Array (0 , room_depth, runout_height_lower), diagonal_radius ”2cm diameter
Else
Rhino.AddCylinder Array(bldg_width, room_depth, counter*room_height), _
Array (bldg_width-adj, room_depth, 0), diagonal_radius ”2cm diameter
End If
counter = counter – 2
Loop

End If

”””””””””””””””””
”Columns””’
‘ make columns that span each room’
”””””””””””””””””

‘# of columns depends on number of rooms

counter = 0

Do While counter <= bldg_rooms ‘creates columns for every room

‘draw back columns
Rhino.AddCylinder Array(counter*room_width, 0, 0), Array (counter*room_width, 0, bldg_height), .2286 ”’ ~.75ft

‘draw front columns
Rhino.AddCylinder Array(counter*room_width, room_depth, 0), Array (counter*room_width, room_depth, bldg_height), .1524 ”’ ~.5ft

‘front left incline bar
‘Bar incline will depend on whether or not the counter is odd or even.
counter = counter + 1

Loop

For counter_h=1 To bldg_floors Step 1
counter = 0
Do While counter <= bldg_rooms

If counter=0 Then
‘for first bar, only show one incline bar
bar_incline1 = Rhino.AddCylinder (Array(counter*room_width,room_depth, room_height*counter_h-incline_bar), Array (counter*room_width+incline_bar, room_depth, room_height*counter_h), skinny_bars)

ElseIf counter = bldg_rooms Then
‘for last bar, show only one bar again
bar_incline2 = Rhino.AddCylinder (Array(counter*room_width-incline_bar, room_depth, room_height*counter_h), Array (counter*room_width, room_depth, room_height*counter_h-incline_bar), skinny_bars)
Else
‘for middle bars, two incline bars
bar_incline1 = Rhino.AddCylinder (Array(counter*room_width, room_depth, room_height*counter_h-incline_bar), Array (counter*room_width+incline_bar, room_depth, room_height*counter_h), skinny_bars)
bar_incline2 = Rhino.AddCylinder (Array(counter*room_width-incline_bar, room_depth, room_height*counter_h), Array (counter*room_width, room_depth, room_height*counter_h-incline_bar), skinny_bars)
End If

counter = counter + 1

Loop
Next

””””””””””””””
”draw bars that go across”
””””””””””””””
For counter_h=1 To bldg_floors Step 1
‘back horizontal bar
bar_horizontal = Rhino.AddCylinder (Array(0, 0, room_height*counter_h), Array (bldg_width, 0, room_height*counter_h), fatter_bars)
‘front horizontal bar
bar_horizontal2 = Rhino.AddCylinder (Array(0, room_depth, room_height*counter_h), Array (bldg_width, room_depth, room_height*counter_h), skinny_bars)
‘front bottom horizontal bar
bar_horizontal3 = Rhino.AddCylinder (Array(0, room_depth, room_height*counter_h-incline_bar), Array (bldg_width, room_depth, room_height*counter_h-incline_bar), skinny_bars)
Next

”””””””””””””””
‘draw bars on top, along y axis
””””””””””””””’
counter = 0
For counter_h=1 To bldg_floors Step 1
Do While counter <= bldg_width
bar_mini = Rhino.AddCylinder (Array(counter, room_depth, room_height*counter_h), Array (counter, 0, room_height*counter_h), skinny_bars) ”~.375ft
counter = counter + .5
Loop
counter = 0
Next

‘rotation point
‘barpt = Array(0, -room_depth, 0)

‘If IsArray(rotationpt) Then
‘ Rhino.RotateObject bar_mini, barpt, -90.0, rotataxis_x, False
‘ Rhino.MoveObject bar_mini, barpt, Array(counter, -room_depth, room_height)
‘End If

Leave a Reply