Hierarchy, Composition and Transformation
This is for exercise 4, the updated version of previous post.
The main thing that got changed is:
– made a function that generates the whole building, as opposed to function that makes one floor then repeat outside of function to create building
– got rid of the balcony feature (changed to open windows), and thus the form of the building
– since balcony is gone, the waviness decreased dramatically
The steps of the programming process:
1. define building size
2. user defines floor number and waviness
3. define the building making function makeBuilding
4. evoke function makeBuilding to make buidling
In the diagrams above, the floor number has kept unchanged, while the waviness changes from 1, 2, 3, 4, accordingly.
Here’s the code:
import rhinoscriptsyntax as rs import math as m rs. DeleteObjects(rs.AllObjects()) #Define essential elements in order to run the function length =55 width = 45 myOrigin = [0,0,0] flHeight = 3.5 nrfloor = rs.GetInteger ("How many floors would you like to build?",20) bldgHeight = nrfloor * flHeight #Define elements that decide how curvy the building will be for the function myAmplitude = rs.GetInteger ("How curvey would you like the building to be",2) nrPtsX = 10 stepX = length/nrPtsX rs.EnableRedraw(False) #Function that makes the building def makeBuilding (origin,nrfloor,Amplitude): curves = [] #create curvy front and back edges of the building for z in rs.frange(0,bldgHeight,flHeight): points = [] for i in rs.frange(0,length,stepX): j = (m.sin(z*m.pi*.1) + m.sin(i*m.pi*.1)) * Amplitude*1.3 points.append(rs.AddPoint([i,j,z])) curves.append(points) flCurve = rs.AddCurve(points) rs.DeleteObjects (points) #based on curvy front and back edges, create floor surfaces frontSurface = [] path = rs.AddLine(myOrigin, [0,0,flHeight]) flSurface = rs.ExtrudeCurve (flCurve,path) curves.append(frontSurface) #based on curvy floors surfaces, create volume of the whole building flBody = [] flWidth = rs.AddLine(myOrigin,[0,width,0]) rs.ExtrudeSurface (flSurface,flWidth) curves.append(flBody) #Evoke the function makeBuilding(myOrigin,nrfloor,myAmplitude)