3.3 PredefinedParameters
HeightofaLevelisfixedat3meters
3.4 Step-by-StepCodedescription
Creatingtheblock:
#Function for generating a block at a time”
def create_block(self):
#Creation of block type A
if int(self.block_type_radiobutton) == 0:
#Creating a single room:
self.room_plane = rs.MovePlane(self.room_plane, self.room_origin[0])
self.room_plane = rs.RotatePlane(self.room_plane , self.room_plane_rotation , [0,0,1])
room = rs.AddRectangle(self.room_plane, self.room_lenght, self.room_width)
#Creating a translation vector to copy with a room edge
rs.EnableObjectGrips(room, enable = True)
translation_Vector_pt1 = rs.ObjectGripLocation(room,0)
translation_Vector_pt2 = rs.ObjectGripLocation(room,1)
rs.EnableObjectGrips(room, enable = False)
translation_Vector = rs.VectorCreate(translation_Vector_pt2,translation_Vector_pt1)
#Copying rooms along the lenght
self.all_rooms=[]
self.all_rooms.append(room)
i = 0
while i in range(self.num_of_rooms-1):
room = rs.CopyObjects(room,translation_Vector)
self.all_rooms.append(room)
i += 1
#Creating corridor origin
room_first = self.all_rooms[0]
rs.EnableObjectGrips(room_first, enable=True)
corridor_first_p = rs.ObjectGripLocation(room_first, 3)
rs.EnableObjectGrips(room_first, enable=False)
#Creating the corridor automatically
corridor_origin = [corridor_first_p.X,corridor_first_p.Y,corridor_first_p.Z]
self.corridor_plane = rs.MovePlane(self.corridor_plane, corridor_origin)
self.corridor_plane = rs.RotatePlane(self.corridor_plane, self.room_plane_rotation , [0,0,1]) corridor_lenght = float(self.num_of_rooms*self.room_lenght)
corridor_Curve = rs.AddRectangle(self.corridor_plane, corridor_lenght,self.width_corridor )
#Adding the curve to a list to export self.corridor_list.append(corridor_Curve)
print(" Succesfully Generated a new block - Type A ")
text_plane = rs.WorldXYPlane()
#Geting Centroid of all rooms for keys
self.all_centroid = [] for curve in self.all_rooms: centroid = rs.CurveAreaCentroid(curve) self.all_centroid.append(centroid[0])
#Creating a dict for every block generated with keys as centroid and curves as values self.block = dict(zip(self.all_centroid,self.all_rooms))
return self.block
Selectingoriginforblock:
def origin_select(self, sender, e):
origin_select.Click += SelectPtsButtonClick
#Select points from Rhino and return to dialog
def OnGetRhinoObjects(self, sender, e):
pts = rs.GetPoint('Select point of origin for rooms :')
p = (pts.X),(pts.Y),(pts.Z)
self.origin.insert(0,p)
print("Origin selected: ")
print((self.origin)[0])
Blockgeneratebutton:
def block_generate_ButtonClick(self, sender, e):
if isinstance ( sender , forms.Button): if len(self.origin)==0:
print('Error : Origin point to be selected to generate block!')
else:
Rhino.UI.EtoExtensions.PushPickButton(self, self.OnRowGenerate)
#calling function to create a block self.block = self.create_block()
#Adding every block at generate to all blocks list self.all_blocks.append(self.block)
print("Total no of rooms:",len(self.block),type(self.block))
#Reseting the world plane after generating a block self.room_plane = rs.WorldXYPlane() self.corridor_plane = rs.WorldXYPlane()
Drawcorebutton:
def draw_core_ButtonClick(self , sender ,e): if isinstance (sender , forms.Button): if len(self.all_blocks) == 0:
print("Error : Cannot draw core before generating atleast one block!") else:
Rhino.UI.EtoExtensions.PushPickButton(self, self.OnGetCorePoints)
Pickentrancebutton:
def pick_entrance_ButtonClick(self , sender ,e): if isinstance (sender , forms.Button):
if len(self.all_blocks) == 0:
print("Error : Cannot pick entrance before generating atleast one block!") else:
Rhino.UI.EtoExtensions.PushPickButton(self, self.OnGetEntrancePoint) sender.Text = "Entrance Selected"
Pickentrancebutton:
# Delete rooms on core function
def delete_rooms_on_core(self): centroid_delete = [] for block in self.all_blocks: for centroid,room in block.items(): centroid_point = rs.AddPoint(centroid)
value = rs.PointInPlanarClosedCurve(centroid_point ,self.core_curve) if value == 1 : centroid_delete.append(centroid) rs.DeleteObject(room) rs.DeleteObjects(centroid_point) else: pass
print('No of rooms deleted by core',len(centroid_delete)) for block in self.all_blocks: for key in centroid_delete: block.pop(key,None)
15 Page
16 Page
Spatialcalculatebutton:
# Spatial calculation function
def OnCalculateButtonClick(self,sender,e):
self.delete_rooms_on_core()
print("Total no of blocks" ,len(self.all_blocks),type(self.all_blocks))
area_generated_list = [] for block in self.all_blocks:
single_unit_curve = list(block.values())[0]
unit_area = rs.CurveArea(single_unit_curve)
block_area = unit_area[0]*len(block)
area_generated_list.append(block_area)
print('Area Generaed list',area_generated_list)
self.volume_generated_textbox.Text = str("Total_volume_Generated (Cu.M) : ")+ str(sum(area_generated_list)*self.no_of_levels)
self.area_singleunit_textbox.Text = str("Singleunit_area_Generated (Sq.M) : ") + str(unit_area[0]) self.area_generated_textbox.Text = str("Total_floorarea_Generated (Sq.M) : ") + str(sum(area_generated_list))
FunctiontocalltheETOform:
# Function to call the Configurator Dialog def RequestHouseGenerator():
dialog = ConfiguratorDialog();
rc = dialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow)
all_blocks_list = dialog.get_all_blocks_list() no_of_levels = dialog.get_no_of_levels()
room_lenght = dialog.get_room_lenght()
room_width = dialog.get_room_width()
corridor_list = dialog.get_corridor_list() core_list = dialog.get_core_list()
balcony_type = dialog.get_balcony_type()
entrance_points = dialog.get_entrance_points()
block_rotation = dialog.get_block_rotation()
return all_blocks_list, no_of_levels, room_lenght, room_width, corridor_list, core_list , balcony_type , entrance_points,block_rotation
MainFunction:
if __name__ == "__main__":
#Getting the vaiables from the dialog all_blocks_list, no_of_levels, room_lenght, room_width, corridor_list, core_list,balcony_type ,entrance_points,block_rotation = RequestHouseGenerator()
#Creating balconies type 1
def create_balcony_1(type,room_lenght,room_width):
room_lenght = room_lenght
room_width = room_width
if type == 1 :
import rhinoscriptsyntax as rs rs.CurrentLayer("Default")
balcony_depth = 1.5
room_plane = rs.WorldXYPlane()
#room_plane = rs.RotatePlane(room_plane,180,(0,0,1))
room = rs.AddRectangle(room_plane, room_lenght, room_width)
balcony_translation = [0,-balcony_depth,0]
rs.EnableObjectGrips(room, enable=True) print("Generating balcony 1")
balcony_first_pt = rs.ObjectGripLocation(room, 0)
balcony_second_pt = rs.ObjectGripLocation(room, 1)
balcony_edge = rs.AddLine(balcony_first_pt,balcony_second_pt)
balcony_third_pt = rs.CurveMidPoint(balcony_edge, segment_index=-1)
balcony_third_pt = rs.MoveObject(balcony_third_pt, balcony_translation)
balcony_points = [balcony_second_pt,balcony_third_pt,balcony_first_pt]
balcony_curve = rs.AddPolyline(balcony_points)
rs.EnableObjectGrips(room, enable=False)
path = rs.AddLine([0,0,0], [0,0,1.0])
balcony = rs.ExtrudeCurve(balcony_curve , path )
return balcony
elif type == 2: import rhinoscriptsyntax as rs
rs.CurrentLayer("Default")
balcony_depth = 1.5
room_plane = rs.WorldXYPlane()
#room_plane = rs.RotatePlane(room_plane,180,(0,0,1))
room = rs.AddRectangle(room_plane, room_lenght, room_width)
balcony_translation = [0,-balcony_depth,0]
rs.EnableObjectGrips(room, enable=True)
print("Generating balcony 1")
balcony_first_pt = rs.ObjectGripLocation(room, 0)
balcony_second_pt = rs.ObjectGripLocation(room, 1)
balcony_edge = rs.AddLine(balcony_first_pt,balcony_second_pt)
balcony_third_pt = rs.CurveMidPoint(balcony_edge, segment_index=-1)
balcony_third_pt = rs.MoveObject(balcony_third_pt, balcony_translation)
balcony_points = [balcony_second_pt,balcony_third_pt,balcony_first_pt]
balcony_curve = rs.AddPolyline(balcony_points)
rs.EnableObjectGrips(room, enable=False)
path = rs.AddLine([0,0,0], [0,0,1.0])
balcony = rs.ExtrudeCurve(balcony_curve , path )
return balcony
else: pass
17 Page
18|Page
1:
Balconytype
#Creating balconies type 2
def create_balcony_2(type,room_lenght,room_width):
room_lenght = room_lenght
room_width = room_width
if type == 1:
import rhinoscriptsyntax as rs
rs.CurrentLayer("Default")
balcony_depth = 2
balcony_depth_2 = 1
room_plane = rs.WorldXYPlane()
#room_plane = rs.RotatePlane(room_plane,180,(0,0,1))
room = rs.AddRectangle(room_plane, room_lenght, room_width)
rs.EnableObjectGrips(room, enable=True)
balcony_first_pt = rs.ObjectGripLocation(room, 0)
balcony_second_pt = rs.ObjectGripLocation(room, 1)
balcony_edge = rs.AddLine(balcony_first_pt,balcony_second_pt)
balcony_third_pt = rs.CurveMidPoint(balcony_edge, segment_index=-1)
balcony_third_new_pt = (balcony_third_pt[0],balcony_third_pt[1]-balcony_depth_2,balcony_third_pt[2] )
balcony_first_new_pt = (balcony_first_pt[0],balcony_first_pt[1]-balcony_depth,balcony_first_pt[2] )
balcony_second_new_pt = (balcony_second_pt[0],balcony_second_pt[1]-balcony_depth,balcony_second_pt[2])
print("Generating balcony 2 - Type 1")
rs.EnableObjectGrips(room, enable=False)
balcony_points_1 = [balcony_second_pt,balcony_third_pt,balcony_third_new_pt,balcony_second_new_pt,balcony_second_pt]
balcony_part_1 = rs.AddPolyline(balcony_points_1)
balcony_points_2 = [balcony_third_pt,balcony_first_pt,balcony_first_new_pt,balcony_third_new_pt,balcony_third_pt]
balcony_part_2 = rs.AddPolyline(balcony_points_2)
balcony_top_first_pt = (balcony_first_pt[0],balcony_first_pt[1],balcony_first_pt[2]+3)
balcony_top_second_pt = (balcony_second_pt[0],balcony_second_pt[1],balcony_second_pt[2]+3)
balcony_top_third_pt = (balcony_third_pt[0],balcony_third_pt[1],balcony_third_pt[2]+3)
balcony_top_first_new_pt = (balcony_first_new_pt[0],balcony_first_new_pt[1]+balcony_depth_2,balcony_first_new_pt[2]+3)
balcony_top_second_new_pt = (balcony_second_new_pt[0],balcony_second_new_pt[1]+balcony_depth_2,balcony_second_new_pt[2]+3)
balcony_top_third_new_pt = (balcony_third_new_pt[0],balcony_third_new_pt[1]-balcony_depth_2,balcony_third_new_pt[2]+3)
balcony_points_3 = [balcony_top_second_pt,balcony_top_third_pt,balcony_top_third_new_pt,balcony_top_second_new_pt,balcony_top_second_pt]
balcony_top_part_1 = rs.AddPolyline(balcony_points_3)
balcony_top_part_1_srf = rs.AddPlanarSrf(balcony_top_part_1)
balcony_points_4 = [balcony_top_third_pt,balcony_top_first_pt,balcony_top_first_new_pt,balcony_top_third_new_pt,balcony_top_third_pt]
balcony_top_part_2 = rs.AddPolyline(balcony_points_4)
balcony_top_part_2_srf = rs.AddPlanarSrf(balcony_top_part_2)
#balcony = rs.JoinCurves([balcony_part_1,balcony_part_2,balcony_top_part_1,balcony_top_part_2],delete_input=True)
balcony_loft_1 = rs.AddLoftSrf([balcony_part_1,balcony_top_part_1])
balcony_loft_1 = rs.ExplodePolysurfaces(balcony_loft_1)
balcony_loft_2 = rs.AddLoftSrf([balcony_part_2,balcony_top_part_2])
balcony_loft_2 = rs.ExplodePolysurfaces(balcony_loft_2)
balcony_loft_1_trimmed = rs.TrimSurface(balcony_loft_1[3] ,0, (0,1), True )
balcony_loft_1[3] = balcony_loft_1_trimmed #balcony_loft_1 = rs.JoinSurfaces([balcony_loft_1],delete_input=True )
balcony_loft_2_trimmed = rs.TrimSurface(balcony_loft_2[3], 0, (0,1), True )
balcony_loft_2[3] = balcony_loft_2_trimmed #balcony_loft_2 = rs.JoinSurfaces([balcony_loft_2],delete_input=True )
balcony = balcony_loft_1+balcony_loft_2+balcony_top_part_1_srf+balcony_top_part_2_srf
return balcony elif type == 2: import rhinoscriptsyntax as rs rs.CurrentLayer("Default")
balcony_depth = 2
balcony_depth_2 = 1
room_plane = rs.WorldXYPlane()
#room_plane = rs.RotatePlane(room_plane,180,(0,0,1))
room = rs.AddRectangle(room_plane, room_lenght, room_width)
print("Generating balcony 2 - Type 2")
rs.EnableObjectGrips(room, enable=True)
balcony_first_pt = rs.ObjectGripLocation(room, 0)
balcony_second_pt = rs.ObjectGripLocation(room, 1)
balcony_edge = rs.AddLine(balcony_first_pt,balcony_second_pt)
balcony_third_pt = rs.CurveMidPoint(balcony_edge, segment_index=-1)
balcony_third_new_pt = (balcony_third_pt[0],balcony_third_pt[1]-balcony_depth,balcony_third_pt[2] )
balcony_first_new_pt = (balcony_first_pt[0],balcony_first_pt[1]-balcony_depth_2,balcony_first_pt[2] )
balcony_second_new_pt = (balcony_second_pt[0],balcony_second_pt[1]-balcony_depth_2,balcony_second_pt[2])
rs.EnableObjectGrips(room, enable=False)
balcony_points_1 = [balcony_second_pt,balcony_third_pt,balcony_third_new_pt,balcony_second_new_pt,balcony_second_pt]
balcony_part_1 = rs.AddPolyline(balcony_points_1)
balcony_points_2 = [balcony_third_pt,balcony_first_pt,balcony_first_new_pt,balcony_third_new_pt,balcony_third_pt]
balcony_part_2 = rs.AddPolyline(balcony_points_2)
balcony_top_first_pt = (balcony_first_pt[0],balcony_first_pt[1],balcony_first_pt[2]+3)
balcony_top_second_pt = (balcony_second_pt[0],balcony_second_pt[1],balcony_second_pt[2]+3)
balcony_top_third_pt = (balcony_third_pt[0],balcony_third_pt[1],balcony_third_pt[2]+3)
balcony_top_first_new_pt = (balcony_first_new_pt[0],balcony_first_new_pt[1]-balcony_depth_2,balcony_first_new_pt[2]+3)
balcony_top_second_new_pt = (balcony_second_new_pt[0],balcony_second_new_pt[1]-balcony_depth_2,balcony_second_new_pt[2]+3)
balcony_top_third_new_pt = (balcony_third_new_pt[0],balcony_third_new_pt[1]+balcony_depth_2,balcony_third_new_pt[2]+3)
balcony_points_3 = [balcony_top_second_pt,balcony_top_third_pt,balcony_top_third_new_pt,balcony_top_second_new_pt,balcony_top_second_pt]
balcony_top_part_1 = rs.AddPolyline(balcony_points_3)
balcony_top_part_1_srf = rs.AddPlanarSrf(balcony_top_part_1)
balcony_points_4 = [balcony_top_third_pt,balcony_top_first_pt,balcony_top_first_new_pt,balcony_top_third_new_pt,balcony_top_third_pt]
balcony_top_part_2
= rs.AddPolyline(balcony_points_4)
balcony_top_part_2_srf = rs.AddPlanarSrf(balcony_top_part_2)
#balcony = rs.JoinCurves([balcony_part_1,balcony_part_2,balcony_top_part_1,balcony_top_part_2],delete_input=True)
balcony_loft_1 = rs.AddLoftSrf([balcony_part_1,balcony_top_part_1])
balcony_loft_1 = rs.ExplodePolysurfaces(balcony_loft_1)
balcony_loft_2 = rs.AddLoftSrf([balcony_part_2,balcony_top_part_2])
balcony_loft_2 = rs.ExplodePolysurfaces(balcony_loft_2)
balcony_loft_1_trimmed = rs.TrimSurface(balcony_loft_1[3] ,0, (0,1), True )
balcony_loft_1[3] = balcony_loft_1_trimmed
#balcony_loft_1 = rs.JoinSurfaces([balcony_loft_1],delete_input=True )
balcony_loft_2_trimmed = rs.TrimSurface(balcony_loft_2[3], 0, (0,1), True )
balcony_loft_2[3] = balcony_loft_2_trimmed #balcony_loft_2 = rs.JoinSurfaces([balcony_loft_2],delete_input=True )
#balcony = rs.JoinSurfaces([balcony_loft_1,balcony_loft_2],delete_input=True )
balcony = balcony_loft_1+balcony_loft_2+balcony_top_part_1_srf+balcony_top_part_2_srf return balcony else: import rhinoscriptsyntax as rs rs.CurrentLayer("Default")
balcony_depth = 2
balcony_depth_2 = 1 room_plane = rs.WorldXYPlane() #room_plane = rs.RotatePlane(room_plane,180,(0,0,1))
room = rs.AddRectangle(room_plane, room_lenght, room_width)
print("Generating balcony 2 - Type 2")
rs.EnableObjectGrips(room, enable=True)
balcony_first_pt = rs.ObjectGripLocation(room, 0)
balcony_second_pt = rs.ObjectGripLocation(room, 1)
19|Page Balconytype2:
20 Page
balcony_edge = rs.AddLine(balcony_first_pt,balcony_second_pt)
balcony_third_pt = rs.CurveMidPoint(balcony_edge, segment_index=-1)
balcony_third_new_pt = (balcony_third_pt[0],balcony_third_pt[1]-balcony_depth,balcony_third_pt[2] )
balcony_first_new_pt = (balcony_first_pt[0],balcony_first_pt[1]-balcony_depth_2,balcony_first_pt[2] )
balcony_second_new_pt = (balcony_second_pt[0],balcony_second_pt[1]-balcony_depth_2,balcony_second_pt[2])
rs.EnableObjectGrips(room, enable=False)
balcony_points_1 = [balcony_second_pt,balcony_third_pt,balcony_third_new_pt,balcony_second_new_pt,balcony_second_pt]
balcony_part_1 = rs.AddPolyline(balcony_points_1)
balcony_points_2 = [balcony_third_pt,balcony_first_pt,balcony_first_new_pt,balcony_third_new_pt,balcony_third_pt]
balcony_part_2 = rs.AddPolyline(balcony_points_2)
balcony_top_first_pt = (balcony_first_pt[0],balcony_first_pt[1],balcony_first_pt[2]+3)
balcony_top_second_pt = (balcony_second_pt[0],balcony_second_pt[1],balcony_second_pt[2]+3)
balcony_top_third_pt = (balcony_third_pt[0],balcony_third_pt[1],balcony_third_pt[2]+3)
balcony_top_first_new_pt = (balcony_first_new_pt[0],balcony_first_new_pt[1]-balcony_depth_2,balcony_first_new_pt[2]+3)
balcony_top_second_new_pt = (balcony_second_new_pt[0],balcony_second_new_pt[1]-balcony_depth_2,balcony_second_new_pt[2]+3)
balcony_top_third_new_pt = (balcony_third_new_pt[0],balcony_third_new_pt[1]+balcony_depth_2,balcony_third_new_pt[2]+3)
balcony_points_3 = [balcony_top_second_pt,balcony_top_third_pt,balcony_top_third_new_pt,balcony_top_second_new_pt,balcony_top_second_pt]
balcony_top_part_1 = rs.AddPolyline(balcony_points_3)
balcony_top_part_1_srf = rs.AddPlanarSrf(balcony_top_part_1)
balcony_points_4 = [balcony_top_third_pt,balcony_top_first_pt,balcony_top_first_new_pt,balcony_top_third_new_pt,balcony_top_third_pt]
balcony_top_part_2 = rs.AddPolyline(balcony_points_4)
balcony_top_part_2_srf = rs.AddPlanarSrf(balcony_top_part_2)
#balcony = rs.JoinCurves([balcony_part_1,balcony_part_2,balcony_top_part_1,balcony_top_part_2],delete_input=True)
balcony_loft_1 = rs.AddLoftSrf([balcony_part_1,balcony_top_part_1])
balcony_loft_1 = rs.ExplodePolysurfaces(balcony_loft_1)
balcony_loft_2 = rs.AddLoftSrf([balcony_part_2,balcony_top_part_2])
balcony_loft_2 = rs.ExplodePolysurfaces(balcony_loft_2)
balcony_loft_1_trimmed = rs.TrimSurface(balcony_loft_1[3] ,0, (0,0.01), True )
balcony_loft_1[3] = balcony_loft_1_trimmed
#balcony_loft_1 = rs.JoinSurfaces([balcony_loft_1],delete_input=True )
balcony_loft_2_trimmed = rs.TrimSurface(balcony_loft_2[3], 0, (0,0.01), True )
balcony_loft_2[3] = balcony_loft_2_trimmed
#balcony_loft_2 = rs.JoinSurfaces([balcony_loft_2],delete_input=True )
#balcony = rs.JoinSurfaces([balcony_loft_1,balcony_loft_2],delete_input=True )
balcony = balcony_loft_1+balcony_loft_2+balcony_top_part_1_srf+balcony_top_part_2_srf return balcony
Translationofthebalconies:
#Translating the balconies def balcony_translation(all_blocks_list,balcony_type,no_of_levels,room_lenght,room_width): balcony_curves_list=[] no_of_levels = no_of_levels room_lenght = room_lenght room_width = room_width def calcDist(p1,p2): if len(p1) == 2 or len(p2) == 2:
dist = math.sqrt( (p2[0] - p1[0])**2 + (p2[1] - p1[1])**2 ) else: dist = math.sqrt( (p2[0] - p1[0])**2 + (p2[1] - p1[1] )**2 + (p2[2] - p1[2])**2 )
return dist
def calcVect(p1,p2): lenght = calcDist(p1,p2)
if len(p1) == 2 or len(p2) == 2:
vector = ((p2[0] - p1[0])/lenght,(p2[1] - p1[1])/lenght,0)
else:
vector = ((p2[0] - p1[0])/lenght,(p2[1] - p1[1])/lenght,(p2[2] - p1[2])/lenght)
return vector
def cross_prod(v1,v2):
c = [v1[1] * v2[2] - v1[2] * v2[1], v1[2] * v2[0] - v1[0] * v2[2], v1[0] * v2[1] - v1[1] * v2[0]]
return c
def matrixTransformation_LCS2GCS(v1,v2,v3,p1):
matrix=[]
matrix.append([v1[0],v2[0],v3[0],p1[0]])
matrix.append([v1[1],v2[1],v3[1],p1[1]])
matrix.append([v1[2],v2[2],v3[2],p1[2]]) matrix.append([0,0,0,1])
21 Page
22|Page Balconytype3:
def balc(type,balcony_type):
if balcony_type == 1:
obj = create_balcony_1(type,room_lenght,room_width)
elif balcony_type == 2:
obj = create_balcony_2(type,room_lenght,room_width)
elif balcony_type == 3:
obj = create_balcony_3(type,room_lenght,room_width)
else:
print("Invalid Balcony Type")
rs.EnableObjectGrips(room, enable=True)
balcony_first_pt = rs.ObjectGripLocation(room, 0)
balcony_second_pt = rs.ObjectGripLocation(room, 1)
balcony_third_pt = rs.ObjectGripLocation(room , 2)
balcony_fourth_pt = rs.ObjectGripLocation(room,3)
rs.EnableObjectGrips(room, enable=False)
p1 = rs.CreatePoint(balcony_first_pt)
p2 = rs.CreatePoint(balcony_second_pt)
p3 = rs.CreatePoint(balcony_fourth_pt)
v1 = calcVect(p1,p2)
v2 = calcVect(p1,p3)
v3 = cross_prod(v1,v2)
if obj:
rs.TransformObject(obj,matrixTransformation_LCS2GCS(v1,v2,v3,p1))
balcony_curves_list.append(obj)
for block in all_blocks_list:
curves = list(block.values())
if no_of_levels == 2: for room in curves:
balc(3,balcony_type)
level_1 = rs.CopyObjects(curves,(0,0,3))
level_1_odd = level_1[::2]
level_1_even = level_1[1::2] for room in level_1_odd:
balc(1,balcony_type) for room in level_1_even: balc(2,balcony_type)
elif no_of_levels == 3: for room in curves:
balc(3,balcony_type)
level_1 = rs.CopyObjects(curves,(0,0,3)) level_2 = rs.CopyObjects(level_1,(0,0,3)) for room in level_1: balc(1,balcony_type) for room in level_2: balc(2,balcony_type) else: for room in curves:
balc(3,balcony_type)
level_1 = rs.CopyObjects(curves,(0,0,3))
level_2 = rs.CopyObjects(level_1,(0,0,3))
level_3 = rs.CopyObjects(level_2,(0,0,3)) for room in level_1:
balc(1,balcony_type) for room in level_2: balc(2,balcony_type) for room in level_3:
balc(1,balcony_type)
return balcony_curves_list
Createfacadefunction:
# Create the facade at the origin for one level def create_facade(curvelenght): curvelenght = curvelenght if curvelenght < 10: length_transom = (curvelenght-0.45)/8 mullions = [] transoms = [] plane = rs.WorldXYPlane() plane = rs.MovePlane(plane, [0,0,3]) mull = rs.AddRectangle(plane, 0.05, 0.11) mull = rs.ExtrudeCurveStraight(mull, [0,0,0], [0,0,1.5]) rs.CapPlanarHoles(mull) mullions.append(mull) plane = rs.MovePlane(plane,(0.05,0,3)) transom = rs.AddRectangle(plane, float(length_transom), 0.11) transom = rs.ExtrudeCurveStraight(transom, [0,0,0], [0,0,0.05])
rs.CapPlanarHoles(transom) transoms.append(transom) transom2 = rs.CopyObject(transom, [0,0,1.45])
transoms.append(transom2) for i in range(0, 9):
mull1 = rs.CopyObject(mull, [(length_transom+0.05)*i,0,0])
mullions.append(mull1) for j in range(0, 8):
tran1 = rs.CopyObject(transom, [(length_transom+0.05)*j,0,0])
transoms.append(tran1)
tran2 = rs.CopyObject(transom2, [(length_transom+0.05)*j,0,0])
transoms.append(tran2)
print("Facade generated - Type 1")
else:
length_transom = (curvelenght-0.85)/16
mullions = []
transoms = []
plane = rs.WorldXYPlane()
plane = rs.MovePlane(plane, [0,0,3])
mull = rs.AddRectangle(plane, 0.05, 0.11)
mull = rs.ExtrudeCurveStraight(mull, [0,0,0], [0,0,1.5])
rs.CapPlanarHoles(mull)
mullions.append(mull)
plane = rs.MovePlane(plane,(0.05,0,3))
transom = rs.AddRectangle(plane, float(length_transom), 0.11)
transom = rs.ExtrudeCurveStraight(transom, [0,0,0], [0,0,0.05])
rs.CapPlanarHoles(transom)
transoms.append(transom) transom2 = rs.CopyObject(transom, [0,0,1.45])
transoms.append(transom2) for i in range(0, 17):
mull1 = rs.CopyObject(mull, [(length_transom+0.05)*i,0,0]) mullions.append(mull1) for j in range(0, 16):
tran1 = rs.CopyObject(transom, [(length_transom+0.05)*j,0,0])
transoms.append(tran1)
tran2 = rs.CopyObject(transom2, [(length_transom+0.05)*j,0,0])
transoms.append(tran2)
print("Facade Generated - Type 2")
return mullions + transoms
23 Page return matrix
24 Page
3.6 FolderStructure
Allthefunctionsarespiltintothefollowingcategories
MainpythonfiletocalltheETOformandcallBuildfunctions
HTMLcodeforETOformcalledusingwebview
Functionstocreatethebuilding
Functionstocreatethefacadeparametrically
25|Page 3.5 HTMLFront-endofETOform 26|Page
4.1KarambaDefinition(Building)
ReferencinggeometrygeneratedbypythoncodeusingLayersandElefrontPlugin
WindloadCalculation
CreatingStaticelementsinKaramba
27|Page
Chapter4–StructureAnalysis
28|Page
29|Page
loads
AddingGravityandUniformlydistributed
30|Page
ModelViews,AndDeflection
ModelView
BeamView
ShellView
ModelviewwithFacade