anna 20120417

April 17

#Integrating all classes so far, and scaling them accordingly

import rhinoscriptsyntax as rs
import math

class mainCore():
def __init__(self,radius):
self.center = [0,0,0]
blue = rs.AddLayer(“Cores”,[200,0,0])
self.r = radius

# Creating the smaller cores
c = Core(self.r/2,[self.r/2,0,0],540)
self.core1 = c.getCore()
c2 = rs.RotateObject(self.core1,self.center,120,axis=None,copy=True)
self.core2 = rs.ScaleObject(c2,self.center,[1,1,0.75])
c3 = rs.RotateObject(self.core1,self.center,240,axis = None, copy=True)
self.core3 = rs.ScaleObject(c3,self.center,[1,1,0.6])

# Assigning a layer to the cores
rs.ObjectLayer(self.core1,”Cores”)
rs.ObjectLayer(self.core2,”Cores”)
rs.ObjectLayer(self.core3,”Cores”)

def getCenter(self):
return self.center

class Core():
def __init__(self,radius,center,height):
self.r = radius
self.c = center
self.h = height
self.core = None
self.draw()

def draw(self):
self.core = rs.AddCylinder(self.c,self.h,self.r,True)

def getCore(self):
return self.core

class Stairs():
def __init__(self):
self.center(0.5)
s = self.stairs(0.5)
s = rs.MoveObjects(s,[6.5,0,0])
s = rs.RotateObjects(s,[0,0,0],120)
self.copy(s)

def center (self,coreradius):
rs.AddLayer(“StairCore”, [0,0,0])
rs.CurrentLayer(“StairCore”)
base = [6.5, 0, 0]
core = rs.AddCylinder (base, 405, coreradius, cap=True)
core = rs.RotateObject(core,[0,0,0],120)

def stairs (self,coreradius):
rs.AddLayer(“Stairs”, [0,30,0])
rs.CurrentLayer(“Stairs”)

plane = rs.WorldXYPlane()
width = 1
height = coreradius+4
stairnumber = 19
rotation = 360/stairnumber
rise = 1/stairnumber

start = [0, 0, 0]
end = [0, 0, -0.02]
path = rs.AddLine (start, end)

rectangle = rs.AddRectangle (plane, width, height)
move = [0.25, 0.25, 0]
path2 = rs.VectorAdd(start, move)
movedrectangle = rs.MoveObject(rectangle, move)

stair = rs.ExtrudeCurve (rectangle, path)
rs.DeleteObject(rectangle)
if stair:
rs.CapPlanarHoles (stair)

stairs = []

for i in range (0,stairnumber,1):
rotatedstair = rs.RotateObjects (stair, start, rotation)
copiedstair = rs.CopyObjects (rotatedstair, [0, 0, i*1])
stairs.append(copiedstair)
rs.DeleteObject(stair)
return stairs

def copy (self, stair):
index = range (int(21))
for i in index:
copiedstairs = rs.CopyObjects (stair, [0, 0, i*19])
rs.DeleteObjects (stair)
return copiedstairs
class Floors():
def __init__(self):
self.center = [0,0,0]
self.tot = 600 # total height
self.h = 10 # height of story
self.r = 50 # starting floor radius
self.t = 1 # thickness of wall
self.floorList = [] # list of all floors
self.firstFloor()
self.copyFloors()

def firstFloor(self):
# Floor
baseOutline = rs.AddCircle(self.center,self.r)
basePlane = rs.AddPlanarSrf(baseOutline)
# Walls
wall1 = rs.AddCylinder(self.center,[0,0,self.h],self.r,True)
wall2 = rs.AddCylinder(self.center,[0,0,self.h],self.r-self.t,True)
wall = rs.BooleanDifference(wall1,wall2)
win = Windows()
win.draw(wall)
#Ceiling
ceiling = rs.CopyObject(basePlane,[0,0,self.h])
story = rs.GetObjects(“Select first floor”)
self.floorList.append(story)

def copyFloors(self):
story = self.floorList[0]
for i in range(int(self.tot/self.h)):
# Defining scale factor
if i<25:
f = 1+0.95*math.sin(i/8)
else:
f = f = 0.8+0.8*math.sin((i-24)/8)

oneStory = rs.CopyObjects(story)
# innerWalls =
# oneStory.append(innerWalls)
oneStory = rs.ScaleObjects(oneStory,self.center,[f,f,1])
oneStory = rs.MoveObjects(oneStory,[0,0,self.h*(i+1)])
self.floorList.append(oneStory)

class MeetingFloor():
def __init__(self,height):
self.center = [0,0,height]
self.h = 10
self.r = 18
self.draw()
def draw(self):
offset = [0,-18,0]
center = rs.VectorAdd(self.center,offset)
hall = rs.AddCircle(center,36)

class Windows():
def __init__(self):
rs.AddLayer(“Windows”, [0,0,0])
rs.CurrentLayer(“Windows”)
self.height = 8
self.width = 5
self.center = [0,0,0]
self.offset = 1 # Feet above the ground at which window starts
def draw(self,walls):
pt1 = [55,-self.width/2,self.offset]
pt2 = [55,self.width/2,self.offset]
pt3 = [-55,self.width/2,self.offset]
pt4 = [-55,-self.width/2,self.offset]
pt5 = [55,-self.width/2,self.offset+self.height]
pt6 = [55,self.width/2,self.offset+self.height]
pt7 = [-55,self.width/2,self.offset+self.height]
pt8 = [-55,-self.width/2,self.offset+self.height]
pts = [pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8]

box = rs.AddBox(pts)
boxes = []
boxes.append(box)

for i in range(0,30):
angle=i*6
newBox = rs.RotateObject(box,self.center,angle,axis=None,copy=True)
boxes.append(newBox)

windows = rs.BooleanDifference(walls,boxes)
return windows

f = Floors()
c = mainCore(13)
s = Stairs()

Leave a comment