############################## # hausuebung 07 B: IMPROVED facade panels and UN building ############################## import rhinoscriptsyntax as rs import random, time, sys sys.path.append("/Users/anny.more/Documents/studium/5. semester/DM2") sys.path.append("P:/") import DM_lib as dm ############################## rs.UnitSystem(4) # km = 5, meters = 4, cm = 3 etc rs.ShowGrid(None, 0) # grid > 0 = off rs.ShowGridAxes(None, 1) # y/y/z axen display > 0/1 = off/on rs.ViewDisplayMode(rs.CurrentView(), "shaded") rs.Command("cplane w t enter", 0) # cPlane World Top dm.PointRadius(displayModeX=0, rad=3, styl=3) dm.printDisplay(1) # nomen est omen rs.EnableRedraw(0) ######################################################################################### # UN BUILDING ######################################################################################### ###_________________________________________# ### # floors = H = dm.H = 40 # default=40 / incl roof slabs = L = dm.L = 11 # default=11 depth = D = dm.D = 4 # default= 4 / division in building_depth floorHeight = fH = dm.fH = 4.0 # default= 4.0 / 4.0*(H-1) = 156 meters # ################ # get from DM_lib as dm: UnoGridCoords = dm.UnoGridCoords # get gridCoords L*D*H = 1760 UnoPanelCoords = dm.UnoPanelCoords # get panelCoords [frontPanels, backPanels, sidePanels, upSidePanels] / default arguments s.u. ################____________________________# ################ lengthVec = lVec = rs.VectorUnitize(rs.VectorSubtract( dm.getUnoCoord(0, 0, 0), dm.getUnoCoord(1, 0, 0) )) ## rs.AddPoint( dm.getUnoCoord(1, 0, 0) ) depthVec = dVec = rs.VectorUnitize(rs.VectorSubtract( dm.getUnoCoord(0, 1, 0), dm.getUnoCoord(0, 0, 0) )) ## rs.AddPoint( dm.getUnoCoord(0, 1, 0) ) ################ ########################################################################################### UnoPanelCoords = dm.getUNpanelCoords(anzL=10*7, anzH=39, anzD=3, stepL=1, stepH=1, stepD=1) ### = all ~windows_panels BigPanelCoords = dm.getUNpanelCoords(anzL=10*1, anzH=39, anzD=3, stepL=2, stepH=6, stepD=2) ### = all ~windows_panels UnoPanelCoords = dm.getUNpanelCoords(anzL=10*1, anzH=39, anzD=3, stepL=1, stepH=3, stepD=1) ### = standard for hu_06 ########################################################################################### ############################################################# frontPanels = UnoPanelCoords[0] ### list of coordLists ! backPanels = UnoPanelCoords[1] sidePanels = UnoPanelCoords[2] upSidePanels = UnoPanelCoords[3] allPanels = UnoPanelCoords[4] ################################# dm.newEmptyLayer("UNO::setUp", [120,120,240]) if 1: ### SETUP rs.ObjectColor(rs.AddCurve( [dm.getUnoCoord(0,0,0), dm.getUnoCoord(0,0,39), dm.getUnoCoord(10,0,39), dm.getUnoCoord(10,0,0), dm.getUnoCoord(10,3,0), dm.getUnoCoord(0,3,0), dm.getUnoCoord(0,3,39), dm.getUnoCoord(10,3,39)], 1), [100,0,200]) rs.ObjectColor(rs.AddLine( dm.getUnoCoord(0, 0, 0), dm.getUnoCoord(0, 1, 0) ), [222, 0, 0] ) rs.ObjectColor(rs.AddLine( dm.getUnoCoord(0, 0, 0), dm.getUnoCoord(1, 0, 0) ), [0, 222, 0] ) rs.ObjectColor(rs.AddLine( dm.getUnoCoord(0, 0, 0), dm.getUnoCoord(0, 0, 2) ), [0, 0, 222] ) rs.ObjectPrintWidth( rs.AllObjects()[0:4], 1.0 ) rs.ZoomExtents() #for coords in BigPanelCoords[4]: rs.AddCurve( coords, 1 ) for list in frontPanels: rs.AddCurve (list, 1) ######################################################################################### # FACADE PANELS ######################################################################################### if 1: def myPanel(panel, basement=1, auskrag=5, index=None): p0, p1, p2, p3 = panel nVec = dm.normVec3pnts(p0, p2, p3) nVec = rs.VectorScale(nVec, random.uniform(3, 5)) ######## BASEMENT if basement: if p0[2] > -1 and p0[2] < 20: inner_square_offset = 2 extrusion_distance = 10 inner_p0 = dm.pntInbetween(p0, p1, inner_square_offset / rs.Distance(p0, p1)) inner_p1 = dm.pntInbetween(p1, p3, inner_square_offset / rs.Distance(p1, p3)) inner_p2 = dm.pntInbetween(p3, p2, inner_square_offset / rs.Distance(p3, p2)) inner_p3 = dm.pntInbetween(p2, p0, inner_square_offset / rs.Distance(p2, p0)) inner_crv = rs.AddCurve([inner_p0, inner_p1, inner_p3, inner_p2, inner_p0], 1) inner_solid = rs.ExtrudeCurveStraight(inner_crv, [5, 7, 0], [0, extrusion_distance, 0]) if inner_solid: rs.ObjectPrintWidth(inner_solid, 0.1) rs.ObjectColor(inner_solid, [0, 50, 200]) ######## FIRST ROW else: if p0[2] > 20 and p0[2] < 30: # Size of the square panel panel_size = 15 # Center of the square panel center = dm.pntInbetween(p0, p2, 0.5) # Calculate the maximum radius for the shapes max_radius = panel_size / 2 * 0.9 # Edge vectors for the square vec1 = rs.VectorSubtract(p1, p0) # horizontal vec2 = rs.VectorSubtract(p3, p0) # vertical # Normalize edge vectors vec1 = rs.VectorUnitize(vec1) vec2 = rs.VectorUnitize(vec2) # Generate the hexagon hex_points = [] for i in range(6): angle = i * 60.0 rotated_vec = rs.VectorRotate(vec1, angle, nVec) hex_point = rs.VectorAdd(center, rs.VectorScale(rotated_vec, max_radius)) hex_points.append(hex_point) # Generate the star star_points = [] inner_radius = max_radius * 0.5 for i in range(6): # Outer point angle_outer = i * 60.0 vec_outer = rs.VectorRotate(vec1, angle_outer, nVec) outer_point = rs.VectorAdd(center, rs.VectorScale(vec_outer, max_radius)) star_points.append(outer_point) # Inner point angle_inner = angle_outer + 30.0 vec_inner = rs.VectorRotate(vec1, angle_inner, nVec) inner_point = rs.VectorAdd(center, rs.VectorScale(vec_inner, inner_radius)) star_points.append(inner_point) # Z-coordinate of the panel's center z_position = center[2] # Create a single hexagon hex_curve = rs.AddPolyline(hex_points + [hex_points[0]]) # Set hexagon width and color rs.ObjectPrintWidth(hex_curve, 0.7) rs.ObjectColor(hex_curve, [0, 55, 150]) # Extrude triangles between the star and hexagon for i in range(6): hex_outer1 = hex_points[i] hex_outer2 = hex_points[(i + 1) % 6] star_inner = star_points[i * 2 + 1] # Move the inner point (star_inner) along the normal direction move_distance = random.uniform(0.1, 0.3) star_inner_popped = rs.VectorAdd(star_inner, rs.VectorScale(nVec, move_distance)) # Create the new triangle curve with the moved inner point triangle_points = [hex_outer1, hex_outer2, star_inner_popped] triangle_curve = rs.AddPolyline(triangle_points + [triangle_points[0]]) # Set triangle width and color rs.ObjectPrintWidth(triangle_curve, 0.7) rs.ObjectColor(triangle_curve, [15, 150, 250]) # Extrude the triangle curve to create a solid rs.ExtrudeCurveStraight(triangle_curve, [0, 0, 0], nVec) ######## LAST ROW if p0[2] > 140 and p0[2] < 160: # Size of the square panel panel_size = 9 # Center of the square panel center = dm.pntInbetween(p0, p2, 0.5) # Calculate the maximum radius for the shapes max_radius = panel_size / 2 * 0.9 # Edge vectors for the square vec1 = rs.VectorSubtract(p1, p0) vec2 = rs.VectorSubtract(p3, p0) # Normalize edge vectors vec1 = rs.VectorUnitize(vec1) vec2 = rs.VectorUnitize(vec2) # Generate the hexagon hex_points = [] for i in range(6): angle = i * 60.0 rotated_vec = rs.VectorRotate(vec1, angle, nVec) hex_point = rs.VectorAdd(center, rs.VectorScale(rotated_vec, max_radius)) hex_points.append(hex_point) # Generate the star star_points = [] inner_radius = max_radius * 0.5 for i in range(6): # Outer point angle_outer = i * 60.0 vec_outer = rs.VectorRotate(vec1, angle_outer, nVec) outer_point = rs.VectorAdd(center, rs.VectorScale(vec_outer, max_radius)) star_points.append(outer_point) # Inner point angle_inner = angle_outer + 30.0 # Midway between outer points vec_inner = rs.VectorRotate(vec1, angle_inner, nVec) inner_point = rs.VectorAdd(center, rs.VectorScale(vec_inner, inner_radius)) star_points.append(inner_point) # Z-coordinate of the panel's center z_position = center[2] # Create a single hexagon hex_curve = rs.AddPolyline(hex_points + [hex_points[0]]) # Set hexagon width and color rs.ObjectPrintWidth(hex_curve, 0.7) rs.ObjectColor(hex_curve, [0, 55, 150]) # Extrude triangles between the star and hexagon for i in range(6): # Define the three points of the triangle hex_outer1 = hex_points[i] hex_outer2 = hex_points[(i + 1) % 6] star_inner = star_points[i * 2 + 1] # Move the inner point (star_inner) along the normal direction move_distance = random.uniform(0.5, 1) star_inner_popped = rs.VectorAdd(star_inner, rs.VectorScale(nVec, move_distance)) # Create the new triangle curve with the moved inner point triangle_points = [hex_outer1, hex_outer2, star_inner_popped] triangle_curve = rs.AddPolyline(triangle_points + [triangle_points[0]]) # Set triangle width and color rs.ObjectPrintWidth(triangle_curve, 0.7) rs.ObjectColor(triangle_curve, [15, 150, 250]) # Extrude the triangle curve to create a solid rs.ExtrudeCurveStraight(triangle_curve, [0, 0, 0], nVec) ######## DEFAULT PANELS else: # Size of the square panel panel_size = 12 # Center of the square panel center = dm.pntInbetween(p0, p2, 0.5) # Calculate the maximum radius for the shapes max_radius = panel_size / 2 * 0.9 # Edge vectors for the square vec1 = rs.VectorSubtract(p1, p0) vec2 = rs.VectorSubtract(p3, p0) # Normalize edge vectors vec1 = rs.VectorUnitize(vec1) vec2 = rs.VectorUnitize(vec2) # Generate the hexagon hex_points = [] for i in range(6): angle = i * 60.0 rotated_vec = rs.VectorRotate(vec1, angle, nVec) hex_point = rs.VectorAdd(center, rs.VectorScale(rotated_vec, max_radius)) hex_points.append(hex_point) # Generate the star star_points = [] inner_radius = max_radius * 0.5 for i in range(6): # Outer point angle_outer = i * 60.0 vec_outer = rs.VectorRotate(vec1, angle_outer, nVec) outer_point = rs.VectorAdd(center, rs.VectorScale(vec_outer, max_radius)) star_points.append(outer_point) # Inner point angle_inner = angle_outer + 30.0 vec_inner = rs.VectorRotate(vec1, angle_inner, nVec) inner_point = rs.VectorAdd(center, rs.VectorScale(vec_inner, inner_radius)) star_points.append(inner_point) # Z-coordinate of the panel's center (vertical position) z_position = center[2] # Create a single hexagon (one per panel) hex_curve = rs.AddPolyline(hex_points + [hex_points[0]]) # Set hexagon width and color rs.ObjectPrintWidth(hex_curve, 0.7) rs.ObjectColor(hex_curve, [0, 55, 150]) # Extrude triangles between the star and hexagon (only the inner point moves) for i in range(6): # Define the three points of the triangle hex_outer1 = hex_points[i] hex_outer2 = hex_points[(i + 1) % 6] star_inner = star_points[i * 2 + 1] # Move the inner point (star_inner) along the normal direction move_distance = random.uniform(1, 2) star_inner_popped = rs.VectorAdd(star_inner, rs.VectorScale(nVec, move_distance)) # Create the new triangle curve with the moved inner point triangle_points = [hex_outer1, hex_outer2, star_inner_popped] triangle_curve = rs.AddPolyline(triangle_points + [triangle_points[0]]) # Set triangle width and color rs.ObjectPrintWidth(triangle_curve, 0.7) rs.ObjectColor(triangle_curve, [15, 150, 250]) # Extrude the triangle curve to create a solid rs.ExtrudeCurveStraight(triangle_curve, [0, 0, 0], nVec) for index, panel in enumerate(frontPanels): myPanel(panel, basement=1, auskrag=100, index=index) dm.newEmptyLayer("myPROJ", [200,100,200]) rs.EnableRedraw(1) dm.printDisplay(1) dm.newEmptyLayer("Default") ##### help of chatgpt for some parts of the script when i didn't know how to achieve my wanted outcome after trying on my own