import rhinoscriptsyntax as rs rs.DeleteObjects(rs.AllObjects()) #hexagon ground plan def hexagon(center, radius): lines=[] circle = rs.AddCircle(center, radius) points = rs.DivideCurve(circle, 6, create_points=True) if points: points.append(points[0]) polyline = rs.AddPolyline(points) lines.append(rs.AddPolyline(points)) rs.AddPlanarSrf([polyline]) rs.DeleteObject(circle) return points,lines (hex_points,hexa) = hexagon(center=(0, 0, 0), radius=9.5) #facade def add_facade(points, height): start = points[0] end = points[1] top_start = rs.PointAdd(start, (0, 0, height)) top_end = rs.PointAdd(end, (0, 0, height)) facade_corners = [start, end, top_end, top_start, start] rs.AddPolyline(facade_corners) add_facade(hex_points, height=5) def add_facade1(points, height): start1 = points[1] end1 = points[2] top_start1 = rs.PointAdd(start1, (0, 0, height)) top_end1 = rs.PointAdd(end1, (0, 0, height)) facade_corners = [start1, end1, top_end1, top_start1, start1] rs.AddPolyline(facade_corners) add_facade1(hex_points, height=5) def add_facade2(points, height): start2 = points[2] end2 = points[3] top_start2 = rs.PointAdd(start2, (0, 0, height)) top_end2 = rs.PointAdd(end2, (0, 0, height)) facade_corners = [start2, end2, top_end2, top_start2, start2] rs.AddPolyline(facade_corners) add_facade2(hex_points, height=5) def add_facade3(points, height): start3 = points[3] end3 = points[4] top_start3 = rs.PointAdd(start3, (0, 0, height)) top_end3 = rs.PointAdd(end3, (0, 0, height)) facade_corners = [start3, end3, top_end3, top_start3, start3] rs.AddPolyline(facade_corners) add_facade3(hex_points, height=5) def add_facade4(points, height): start4 = points[5] end4 = points[0] top_start4 = rs.PointAdd(start4, (0, 0, height)) top_end4 = rs.PointAdd(end4, (0, 0, height)) facade_corners = [start4, end4, top_end4, top_start4, start4] rs.AddPolyline(facade_corners) add_facade4(hex_points, height=5) #hexagon network def create_hexagon_network(start_point, radius, rows, cols): hexa=[] dx = (3**0.63) * radius dy = 1.73 * radius for row in range(rows): for col in range(cols): x = start_point[0] + col * dx y = start_point[1] + row * dy (points, lines)=hexagon((x, y, start_point[2]), radius) hexa.append(lines) return hexa, height= 5 start = (0,0, height) radius = 0.96 rows = 3 cols = 5 hi=((pow(3,0.5))/2) startpoi= (radius,hi,0) points, = create_hexagon_network(start, radius, rows, cols) rs.MoveObjects(points, startpoi) rs.MoveObjects(points, hex_points[2]) x_axis = rs.VectorCreate((1, 0,0), (0, 0, 0)) #rotate around facade rs.RotateObjects(points,(0,8.227,5),-90, axis=x_axis,copy=False) rotations = [60, 120, -60, -120] for rot in rotations: rs.RotateObjects(points, (0, 0, 0), rot, axis=None, copy=True) #dach base_center = (0, 0, 5) base_radius = 9.5 height = 1 layers = 5 shrink_factor = 0.8 all_hexagons = [] current_center = base_center current_radius = base_radius for i in range(layers): hex_points, hex_lines = hexagon(current_center, current_radius) all_hexagons.append(hex_lines) current_center = (current_center[0], current_center[1], current_center[2] + height) current_radius *= shrink_factor for hex_layer in all_hexagons: for hex_line in hex_layer: if rs.IsCurve(hex_line): start_point = (0, 0, 0) extrusion_vector = (0, 0, 1) extrusion = rs.ExtrudeCurveStraight(hex_line, start_point, extrusion_vector) if extrusion and rs.IsObject(extrusion): rs.CapPlanarHoles(extrusion) ''' for hex_line in hex_lines: start_point = (0, 0, 0) extrusion_vector = (0, 0, 1) extrusion = rs.ExtrudeCurveStraight(hex_line, start_point, extrusion_vector) '''