The final step is to cut out the panels so that one can identify the size of each panel. The facade is cut at the floor plates and then again in quarters in each direction. The method used here is to create a cutting plane and move it to the necessary points to be cut.
#create brep to intersect the surface #and cut the facade into quarters A = (-10,0,0) B = (FloorWidth+10,0,0) E = (-10,0,FloorHeight*FloorNmbr) F = (FloorWidth+10,0,FloorHeight*FloorNmbr) #cut at first quarter then move to next quarter sideA = rs.AddSrfPt ((A,B,F,E)) sideB = rs.MoveObject (sideA, (0,FloorLength/4,0)) sideC = rs.SplitBrep (surface, sideB) sideBm = rs.MoveObject (sideA, (0,FloorLength/4,0)) #cut second quarter sideCm = rs.SplitBrep (sideC[1], sideBm) #move to third quarter then cut third quarter sideBn = rs.MoveObject (sideA, (0,FloorLength/4,0)) sideCn = rs.SplitBrep (sideCm[0], sideBn)
To shorten the code, a function is used to generate the curves and lessen the amount of points.
def randCurve (x,y,a,n,m): #generate random RandPointB = random.uniform (-10,10) RandPointC = random.uniform (-10,10) RandPointD = random.uniform (-10,10) #generate points with random A = ((0,y,0)) B = ((x*1/4,y+RandPointB,0)) C = ((x*1/2,y+RandPointC,0)) D = ((x*3/4,y+RandPointD,0)) E = ((x,y,0)) #create the curve along the x-axis curve = rs.AddCurve ((A,B,C,D,E)) #rotate curve to create 4 sides curveSide = rs.RotateObject (curve, \ (((FloorWidth/2)+n),\ ((FloorLength/2)+m),0), a) return curveSide
Python code for Exercise 4:
import rhinoscriptsyntax as rs
import math as m
import random
rs.EnableRedraw (False)
#delete all objects in file
rs.DeleteObjects (rs.AllObjects())
#get user input
FloorHeight = rs.GetReal ("Enter floor height", 10)
FloorThickness = rs.GetReal ("Enter floor thickness", 2)
FloorLength = rs.GetReal ("Enter floor length", 40)
FloorWidth = rs.GetReal ("Enter floor Width", 30)
FloorNmbr = rs.GetReal ("Enter number of floors", 10)
Plane = rs.WorldXYPlane ()
Path = rs.AddLine ( [0,0,0], [0,FloorLength,0])
#function to generate the curves that create the facade
def randCurve (x,y,a,n,m):
#generate random
RandPointB = random.uniform (-10,10)
RandPointC = random.uniform (-10,10)
RandPointD = random.uniform (-10,10)
#generate points with random
A = ((0,y,0))
B = ((x*1/4,y+RandPointB,0))
C = ((x*1/2,y+RandPointC,0))
D = ((x*3/4,y+RandPointD,0))
E = ((x,y,0))
#create the curve along the x-axis
curve = rs.AddCurve ((A,B,C,D,E))
#rotate curve to create 4 sides
curveSide = rs.RotateObject (curve, \
(((FloorWidth/2)+n),\
((FloorLength/2)+m),0), a)
return curveSide
#function create surfaces
def line (intHeight):
#randCurve creates the 4 sides of the facade
Front = randCurve (FloorWidth,0,0,0,0)
SideA = randCurve (FloorLength, 0,90, \
0,-((FloorLength-FloorWidth)/2))
SideB = randCurve (FloorLength, 0,270, \
((FloorLength-FloorWidth)/2),0)
Back = randCurve (FloorWidth, 0,180,0,0)
#join the 4 sides
box = rs.JoinCurves ((Front, SideA, SideB, Back))
rs.DeleteObjects ((Front,SideA,SideB,Back))
#move the wall depending on the height
rs.MoveObject ( box, (0, 0, intHeight))
return box
#create dyanamic surface through 3 different heights
linesBottom = line (FloorHeight*FloorNmbr*0)
linesMiddle = line (FloorHeight*FloorNmbr*.5)
linesTop = line (FloorHeight*FloorNmbr*1)
surface = rs.AddLoftSrf ([linesBottom, linesMiddle, linesTop])
#create brep to intersect the surface
#and cut the facade into quarters
def panelFront (x):
#create 4 points that extend past the limitations
#of the random facade point generator
A = ((x,-10,0))
B = ((x,FloorLength+10,0))
C = ((x,FloorLength+10,FloorHeight*FloorNmbr))
D = ((x,-10,FloorHeight*FloorNmbr))
#create brep
brep = rs.AddSrfPt ( [A,B,C,D] )
#create vertical panels
panels = rs.IntersectBreps (surface, brep)
rs.DeleteObject (brep)
return panels
#create panel lines
for j in range (1,4):
panelFront (FloorWidth*1/4*j)
#obtain lines for floors from surface and create floor slabs
def slab (Height):
#create 4 points that extend past the limitations
#of the random facade point generator
A = ((-10,-10,Height))
B = ((FloorWidth+10,-10,Height))
C = ((FloorWidth+10,FloorLength+10,Height))
D = ((-10,FloorLength+10,Height))
#create brep
brep = rs.AddSrfPt ( [A,B,C,D] )
#create floor from the curves
floorCurves = rs.IntersectBreps (surface, brep)
PathS = rs.AddLine ( [0,0,0], [0,0,- FloorThickness])
floor = rs.ExtrudeCurve (floorCurves, PathS)
rs.CapPlanarHoles (floor)
rs.DeleteObject (brep)
return floor
#create floor slabs at specified height
for i in range ((int (FloorNmbr+1))):
floor = slab (FloorHeight*i)
#create brep to intersect the surface
#and cut the facade into quarters
A = (-10,0,0)
B = (FloorWidth+10,0,0)
E = (-10,0,FloorHeight*FloorNmbr)
F = (FloorWidth+10,0,FloorHeight*FloorNmbr)
#cut at first quarter then move to next quarter
sideA = rs.AddSrfPt ((A,B,F,E))
sideB = rs.MoveObject (sideA, (0,FloorLength/4,0))
sideC = rs.SplitBrep (surface, sideB)
sideBm = rs.MoveObject (sideA, (0,FloorLength/4,0))
#cut second quarter
sideCm = rs.SplitBrep (sideC[1], sideBm)
#move to third quarter then cut third quarter
sideBn = rs.MoveObject (sideA, (0,FloorLength/4,0))
sideCn = rs.SplitBrep (sideCm[0], sideBn)
rs.DeleteObjects ((sideA, sideB, sideBm, sideBn))
rs.DeleteObject ((Path))
rs.EnableRedraw (True)



