#! python3 import rhinoscriptsyntax as rs import random as ran import flipped_lib as fc rs.DeleteObjects(rs.AllObjects()) def my_panel(points, scale): #name poijnts in quad list rs.AddSrfPt(points) #make first diagonal line (P0,P1,P2,P3) = points rs.AddLine(P0,P2) d_cen1 = rs.VectorDivide(rs.VectorAdd(P0,P2),2) #calc center of first diagonal line #rs.AddPoint(d_cen1) #put point at first diagonal center rs.AddLine(P1,P3) #create a second diagonal line d_cen2 = rs.VectorDivide(rs.VectorAdd(P1,P3),2) #calc center of second diagonal line #rs.AddPoint(d_cen2) #put point at second diagonal center center_pt = rs.VectorDivide(rs.VectorAdd(d_cen1,d_cen2),2) #calc center between diagonal center points #rs.AddPoint(center_pt) #put point at true center point if not (rs.PointCompare(d_cen1,d_cen2)): #make sure the 2 center points are not identical rs.AddLine(d_cen1,d_cen2) #draw line between diagonal center points #prepare vectors for cross product to get normal vec1 = rs.VectorSubtract(P0, center_pt) vec2 = rs.VectorSubtract(center_pt,P3) normal = rs.VectorCrossProduct(vec1, vec2) #calc face normal at true center point u_normal = rs.VectorUnitize(normal) #unitize this normal vector (length1) su_normal = rs.VectorScale(u_normal, scale) #scale unitized normal vector normal_pt = rs.VectorAdd(center_pt, su_normal) #fint point at tip of normal vector #rs.AddPoint(normal_pt) #put point normal_pt rs.AddLine(center_pt, normal_pt) #line to show centered normal vector #create pyramid rs.AddSrfPt([P0, normal_pt, P1]) rs.AddSrfPt([P1, normal_pt, P2]) rs.AddSrfPt([P2, normal_pt, P3]) rs.AddSrfPt([P3, normal_pt, P0]) ######################################## rs.EnableRedraw(False) #quad = [[0,0,0], [10,0,0], [10,0,12], [0,0,12]] #quad = [[0,0,0], [10,4,0], [10,4,12], [0,0,12]] #quad = [[0,0,0], [10,0,0], [10,0,12], [0,2,12]] quad = [[0,0,0], [10,0,0], [8,2,12], [2,2,12]] #quad = [[0,0,0], [10,2,0], [10,-2,12], [0,2,10]] #result_list = fc.PEF_single_face(quad) result_list = fc.PEF_face(7, 10, 8.0, 5.0, 30) result_list = fc.PEF_face_w(7, 10, 8.0, 5.0, 30, 2.0) 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 ce_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 " + str(len(p_list)) + " points and " + str(len(f_list)) + " faces on " + str(zcol) + " levels, "+str(xcol)+" per level!") if 1: for i in range(zcol): for j in range (xcol): points = f_list[i*xcol+j] scale = ran.uniform(0.5, 8.5) my_panel(f_list[i*xcol+j],scale) #rs.AddSrfPt(f_list[i*xcol+j]) ########################################### # 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 1: for i, quad in enumerate(f_list): if i%2: rs.AddSrfPt(quad) if 1: for i in range(zcol): for j in range(xcol): if (i+j)%2: rs.AddSrfPt(f_list[i*xcol+j]) if 1: # 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] scale = ran.uniform(0.3,9.5) my_panel(f_list[i*xcol+j], scale) 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) #loftsurf = rs.AddLoftSrf([plinea, plineb]) 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 1: for line in e_list: mline = rs.AddLine(line[0], line[1]) rs.AddPipe(mline, 0, 0.25, cap=2) for line in e_list: mline = rs.AddLine(line[0], line[1]) rs.AddPipe(mline, 0, 0.3, cap=2) rs.EnableRedraw(True)