import rhinoscriptsyntax as rs import random as ran import flipped_classroom_lib as fc reload(fc) rs.DeleteObjects(rs.AllObjects()) ############################################################### # Panel functions with cassette openings... ############################################################### def my_panel_with_openings(points, scale, offset_factor): (P0, P1, P2, P3) = points # Unpack quad points # Calculate center and normal vector d_cen1 = rs.VectorDivide(rs.VectorAdd(P0, P2), 2) d_cen2 = rs.VectorDivide(rs.VectorAdd(P1, P3), 2) center_pt = rs.VectorDivide(rs.VectorAdd(d_cen1, d_cen2), 2) vec1 = rs.VectorSubtract(P0, center_pt) vec2 = rs.VectorSubtract(center_pt, P3) normal = rs.VectorCrossProduct(vec1, vec2) # Calculate face normal u_normal = rs.VectorUnitize(normal) # Unitize the normal vector su_normal = rs.VectorScale(u_normal, scale) # Scale the normal vector normal_pt = rs.VectorAdd(center_pt, su_normal) # Offset the points inward to create the opening offset_pts = [] for pt in [P0, P1, P2, P3]: vec_to_center = rs.VectorSubtract(center_pt, pt) vec_offset = rs.VectorScale(vec_to_center, offset_factor) offset_pts.append(rs.VectorAdd(pt, vec_offset)) # Create the outer frame of the cassette rs.AddSrfPt([P0, offset_pts[0], offset_pts[1], P1]) rs.AddSrfPt([P1, offset_pts[1], offset_pts[2], P2]) rs.AddSrfPt([P2, offset_pts[2], offset_pts[3], P3]) rs.AddSrfPt([P3, offset_pts[3], offset_pts[0], P0]) # Create the inner pyramid with the opening rs.AddSrfPt([offset_pts[0], normal_pt, offset_pts[1]]) rs.AddSrfPt([offset_pts[1], normal_pt, offset_pts[2]]) rs.AddSrfPt([offset_pts[2], normal_pt, offset_pts[3]]) rs.AddSrfPt([offset_pts[3], normal_pt, offset_pts[0]]) ############################################################### rs.EnableRedraw(False) # Generate Pantheon geometry result_list = fc.PEF_pantheon() p_list = result_list[0] # Pointlist, contains single points e_list = result_list[1] # Horizontal Edgelist, contains lists with two points ve_list = result_list[2] # Vertical Edgelist, contains lists with two points f_list = result_list[3] # Facelist, contains lists with four points (quads) zcol = result_list[4] # Number of levels of faces xcol = result_list[5] # Number of faces in one level print("There are {} points and {} faces on {} levels, {} per level!".format(len(p_list), len(f_list), zcol, xcol)) # Parameters for the panels scale = 0.9 # Scale of the pyramid's height offset_factor = 0.3 # Factor for inward offset to create openings # Create cassettes with openings for i in range(zcol): for j in range(xcol): points = f_list[i * xcol + j] my_panel_with_openings(points, scale, offset_factor) ############################################################################# # DOTS to explain the lists ############################################################################# if 0: # Put a dot on each point and create a Point for i, pt in enumerate(p_list): rs.AddPoint(pt) cmd = "-Dot {} {} _Enter ".format(i, pt) rs.Command(cmd, False) if 0: # Put a dot on each horizontal edge and create a line for i, e in enumerate(e_list): rs.AddLine(e[0], e[1]) cmd = "-Dot {} {} _Enter ".format(i, e[0]) rs.Command(cmd, False) if 0: # Put a dot on each vertical edge and create a line for i, ve in enumerate(ve_list): rs.AddLine(ve[0], ve[1]) cmd = "-Dot {} {} _Enter ".format(i, ve[0]) rs.Command(cmd, False) if 0: # Put a dot on each face and create a surface for i, quad in enumerate(f_list): rs.AddSrfPt(quad) cmd = "-Dot {} {} _Enter ".format(i, quad[0]) rs.Command(cmd, False) ############################################################################# # Some experiments with the lists ############################################################################# if 0: for i, quad in enumerate(f_list): if i % 2: rs.AddSrfPt(quad) if 0: for i in range(zcol): for j in range(xcol): if (i + j) % 2: rs.AddSrfPt(f_list[i * xcol + j]) if 0: # Last row in pantheon ceiling is flat for i in range(zcol): for j in range(xcol): if i != zcol - 1: points = f_list[i * xcol + j] my_panel_with_openings(points, scale, offset_factor) else: rs.AddSrfPt(f_list[i * xcol + j]) if 0: for i in range(zcol): for j in range(xcol): points = f_list[i * xcol + j] (P0, P1, P2, P3) = points cpoints = [P0, P1, P2, P3, P0] plinea = rs.AddCurve(cpoints, 2) plineb = rs.AddCurve(cpoints, 3) rs.Command("-_Loft selid {} selid {} _Enter _Enter _Enter".format(plinea, plineb), False) loftsurf = rs.FirstObject() rs.OffsetSurface(loftsurf, .2, both_sides=True, create_solid=True) if 0: for line in e_list: mline = rs.AddLine(line[0], line[1]) rs.AddPipe(mline, 0, 0.3, cap=2) for line in ve_list: mline = rs.AddLine(line[0], line[1]) rs.AddPipe(mline, 0, 0.2, cap=2) rs.EnableRedraw(True)