############################## import rhinoscriptsyntax as rs import math, random import sys sys.path.append("P:/") import DM_lib as dm # reload(dm) ############################## # UN setup rs.UnitSystem(4) # km = 5, meters = 4, cm = 3, etc. rs.ShowGrid(None, 0) # grid > 0 = off rs.ShowGridAxes(None, 1) # y/y/z axes display > 0/1 = off/on rs.ViewDisplayMode(rs.CurrentView(), "wireframe") rs.Command("cplane w t enter", 0) # cPlane World Top dm.PointRadius(displayModeX=0, rad=3, styl=3) dm.printDisplay(0) rs.EnableRedraw(0) # Fassade Setup floors = H = dm.H = 40 # Default number of floors (height) slabs = L = dm.L = 11 # Default slabs (width) depth = D = dm.D = 4 # Default depth (grid depth divisions) floorHeight = fH = dm.fH = 4.0 # Height of each floor (4 meters) UnoGridCoords = dm.getUnoGridCoords() # Grid coordinates from DM library # Layer setup dm.newEmptyLayer("UNO::Fassade::Shapes", [100, 150, 200]) ################## depthVec = rs.VectorUnitize(rs.VectorSubtract(dm.getUnoCoord(0, 0, 0), dm.getUnoCoord(0, 1, 0))) lengthVec = rs.VectorUnitize(rs.VectorSubtract(dm.getUnoCoord(0, 0, 0), dm.getUnoCoord(1, 0, 0))) ################## #klimt shapes def create_scallop(center, panel_normal, offset, width=3, height=4): """Creates scallop shape.""" center = rs.VectorAdd(center, rs.VectorScale(panel_normal, offset)) radius = width / 2 top = rs.VectorAdd(center, rs.VectorScale(panel_normal, height - radius)) left = rs.VectorAdd(center, [-radius, 0, 0]) right = rs.VectorAdd(center, [radius, 0, 0]) arc = rs.AddArc3Pt(left, right, top) base = rs.AddLine(left, right) return rs.JoinCurves([arc, base]) def create_circular_petal(center, panel_normal, offset, radius=2): """Creates circular petals.""" center = rs.VectorAdd(center, rs.VectorScale(panel_normal, offset)) num_petals = 5 angles = [i * (2 * math.pi / num_petals) for i in range(num_petals)] petals = [] for angle in angles: start = rs.VectorAdd(center, [ radius * math.cos(angle), radius * math.sin(angle), 0 ]) end = rs.VectorAdd(center, [ radius * math.cos(angle + (2 * math.pi / num_petals)), radius * math.sin(angle + (2 * math.pi / num_petals)), 0 ]) petal = rs.AddCurve([center, start, end], degree=3) petals.append(petal) return rs.JoinCurves(petals) def create_u_shape(center, panel_normal, offset, width=3, height=5): """Creates a U-shape.""" center = rs.VectorAdd(center, rs.VectorScale(panel_normal, offset)) top_left = rs.VectorAdd(center, [-width / 2, 0, 0]) top_right = rs.VectorAdd(center, [width / 2, 0, 0]) bottom_left = rs.VectorAdd(center, [-width / 2, -height, 0]) bottom_right = rs.VectorAdd(center, [width / 2, -height, 0]) left_line = rs.AddLine(top_left, bottom_left) right_line = rs.AddLine(top_right, bottom_right) bottom_arc = rs.AddArc3Pt(bottom_left, bottom_right, rs.VectorAdd(center, [0, -height / 2, 0])) return rs.JoinCurves([left_line, bottom_arc, right_line]) def project_shapes_on_fassade(): """Projects shapes onto the fassade grid.""" colors = { "scallop": [255, 215, 0], # Gold "circular_petal": [0, 0, 255], # Blue "u_shape": [0, 0, 0] # Black } offset = 0.5 for h in range(H): for l in range(L): d = D - 1 center = dm.getUnoCoord(l, d, h) # panel_normal = rs.VectorUnitize(depthVec) if (l + d + h) % 3 == 0: shape = create_scallop(center, panel_normal, offset) rs.ObjectColor(shape, colors["scallop"]) elif (l + d + h) % 3 == 1: shape = create_circular_petal(center, panel_normal, offset) rs.ObjectColor(shape, colors["circular_petal"]) else: shape = create_u_shape(center, panel_normal, offset) rs.ObjectColor(shape, colors["u_shape"]) project_shapes_on_fassade() rs.EnableRedraw(1) dm.newEmptyLayer("Default") print("Shapes projected onto the fassade correctly!") ### Circular Pattern Panel Design ### # Basic Settings rs.UnitSystem(4) # Use meters rs.ShowGrid(None, 0) rs.ShowGridAxes(None, 1) rs.ViewDisplayMode(rs.CurrentView(), "rendered") rs.Command("cplane w t enter", 0) rs.EnableRedraw(0) # Parameters panel_size = 5 # Panel size (meters) circle_radius = 2 # Base circle radius num_petals = 5 # Number of petals def createCircularPetalPattern(center, radius, num_petals): angles = [i * (2 * math.pi / num_petals) for i in range(num_petals)] petal_points = [ ( center[0] + radius * math.cos(angle), center[1] + radius * math.sin(angle), center[2], ) for angle in angles ] for i, pt in enumerate(petal_points): next_pt = petal_points[(i + 1) % len(petal_points)] mid_pt = [(pt[0] + next_pt[0]) / 2, (pt[1] + next_pt[1]) / 2, pt[2]] rs.AddCurve([center, pt, mid_pt, next_pt, center], 3) def generatePanels(grid_size_x, grid_size_y, panel_size, radius, num_petals): for x in range(grid_size_x): for y in range(grid_size_y): panel_center = [x * panel_size, y * panel_size, 0] createCircularPetalPattern(panel_center, radius, num_petals) grid_size_x = 10 grid_size_y = 5 generatePanels(grid_size_x, grid_size_y, panel_size, circle_radius, num_petals) # Finalize rs.EnableRedraw(1) print("Circular pattern panels generated.") rs.UnitSystem(4) # Use meters rs.ShowGrid(None, 0) rs.ShowGridAxes(None, 1) rs.ViewDisplayMode(rs.CurrentView(), "rendered") rs.Command("cplane w t enter", 0) rs.EnableRedraw(0) # Parameters scallop_width = 5 scallop_height = 4 rows = 10 columns = 10 overlap_ratio = 0.5 # scallop shape def create_scallop(center, width, height): radius = width / 2 top_center = [center[0], center[1] + height - radius, center[2]] base_left = [center[0] - radius, center[1], center[2]] base_right = [center[0] + radius, center[1], center[2]] # Create semi-circle for the top arc = rs.AddArc3Pt(base_left, base_right, top_center) # Create base line base_line = rs.AddLine(base_left, base_right) # Join the two curves scallop = rs.JoinCurves([arc, base_line]) return scallop def generate_scallop_pattern(rows, columns, width, height, overlap): for row in range(rows): for col in range(columns): x = col * width y = row * height * (1 - overlap) center = [x, y, 0] if row % 2 == 1: center[0] += width / 2 create_scallop(center, width, height) generate_scallop_pattern(rows, columns, scallop_width, scallop_height, overlap_ratio) # Finalize rs.EnableRedraw(1) print("Scallop pattern generated.") ### U-Shaped Pattern Design ### # Settings rs.UnitSystem(4) # Use meters rs.ShowGrid(None, 0) rs.ShowGridAxes(None, 1) rs.ViewDisplayMode(rs.CurrentView(), "rendered") rs.Command("cplane w t enter", 0) rs.EnableRedraw(0) # Parameters u_width = 3 u_height = 5 rows = 10 columns = 10 gap = 1 def create_u_shape(center, width, height): top_left = [center[0] - width / 2, center[1], center[2]] top_right = [center[0] + width / 2, center[1], center[2]] bottom_left = [center[0] - width / 2, center[1] - height, center[2]] bottom_right = [center[0] + width / 2, center[1] - height, center[2]] left_line = rs.AddLine(top_left, bottom_left) right_line = rs.AddLine(top_right, bottom_right) bottom_curve = rs.AddArc3Pt(bottom_left, bottom_right, center) u_shape = rs.JoinCurves([left_line, bottom_curve, right_line]) return u_shape def generate_u_pattern(rows, columns, width, height, gap): for row in range(rows): for col in range(columns): x = col * (width + gap) y = row * (height + gap) center = [x, y, 0] create_u_shape(center, width, height) generate_u_pattern(rows, columns, u_width, u_height, gap) # Finalize rs.EnableRedraw(1) print("U-shaped pattern generated.")