import rhinoscriptsyntax as rs import random as ran import math #cleanup and start from scratch rs.DeleteObjects(rs.AllObjects()) rs.EnableRedraw(False) ################################################################################ #variables ################################################################################ #unit: meters #optionals three_dim=1 #on/off switch for the three dimensional pathway (if it is zero, the bridge is flat, if it is one, the bridge is three dimensional) glass=1 #if this is set to zero, there is no glass in the dome, if it is set to one, there is glass floor=0 #switch for floor (takes a lot of time and computing power if the turns are high) #variables for baseline (arc sequence) z_var_max=7 #how much the z value varies, if the bridge is three dimensional (dont set too high, because it will distort the bridge) z_var_min=0.05 #how much the z value varies (at minimum), if the bridge is three dimensional turns=3 #how many times whole pavillon way curves/turns ("wendungen") arc_length=30 #how long an arc is (combination of turns and arc length determine the length of the bridge) up_downs=arc_length/2 #how many ups and downs there are in the pavillon way (not two many), in relation to the length of the curve/number of turns perc=80 #how likely the points are to move up (how many of them move up, in percent) - important for random factor later #variables for bridge width=4 #width of bridge, also distance between columns (so the pavillons are square(ish)) thick=0.5 #thickness of bridge part stripe=0.3 #thickness of the stripe outside of the column (should be set higher than the column radius) length=1 #initialising variable pod_len_o=1 #length of podest at start pod_len=pod_len_o+0.25 #derived value for the length of the podest #if the flow/offset produces distorted results, up the arc length or reduce the width #variables for columns on top of the bridge hgt=2.7 #height (distance between bridge floor and start of dome) hel_th=0.05 #helix radius for the columns hel_pip=0.08 #radius for piping the helices base_th=0.15 #radius for base (gets lofted later) base_hgt=0.15 #total height of the base of the column #hel_th should be smaller than hel_pip (otherwise the helices are visible) #variables for columns under the bridge thick_col_max=0.20 #radius for cylindric column below bridge at the bottom thick_col_min=0.15 #radius for cylindric column below bridge at the top var_arc=0.5 #how low the arc below the bridge goes under the line size_base_2=0.55 #how big the base of the column is (should be at least twice as big as thick_col_max) base_hgt_2=0.5 #base height for the big column below size_cap=0.55 #how big the top of the column is (at its maximum) cap_hgt=1 #height for top of column (in total) arc_col_thick=0.1 #thickness of the arcs below arc_col_offs=0.1 #how far the arcs are set back thresh=1 #threshold: how high the z-value at a certain point has to be to create columns under, should be higher than base_hgt-thick threshold=thresh+arc_col_thick+thick #derived value so the arc sits correctly vis_arc=0.8 #value that determines how much of the arc is visible #variables for domes hgt_dome=2.5 #dome height (from bottom to peak in the middle) arc_hgt=1.5 #arc on the side of the pavilion height (should be lower than hgt_dome) pip_dome=0.05 #piping radius of the structural arcs in the dome pip_dome_dec=0.03 #piping radius of the decorative curves in the dome dome_top_hgt=0.5 #height of the top part of the dome dome_top_rad=0.1 #maximum radius of the top part of the dome #floor pattern (with leaves) rows=260 #the longer the bridge is, the higher this has to be to achieve the same effect cols=5 #the wider the bridge is, the higher this has to be to achieve the same effect l_hgt=1 #initialising variable l_width=1 #initialising variable pip_floor=0.05 #pipe radius for floor pattern #lists pts=[] #list for all the points for the bridge inner_pts=[] #list for the points on the inner curve outer_pts=[] #list for the points on the outer curve cls=[] #list for columns bridge=[] #list for bridge domes=[] #list for domes flow_obj=[] #list for all objects that are subjected to the flow command leaves=[] #list for all leaves (curves) pattern=[] #list for all leaves (pipes) l_glass=[] #list for glass surfaces leaf1=[] #list for wip leaves leaf2=[] #list for wip leaves 2 ################################################################################ #functions ################################################################################ def make_box(insertion=[0,0,0],xsize=0.5,ysize=10,zsize=0.2): corners=[[0,0,0],[xsize,0,0],[xsize,ysize,0],[0,ysize,0], [0,0,zsize],[xsize,0,zsize],[xsize,ysize,zsize],[0,ysize,zsize]] box=rs.AddBox(corners) rs.MoveObject(box,insertion) return(box) def create_baselines(): global help_line global length global line global line_offs global inner1 global inner2 points=[] #points for creating a polyline with the arc command for i in range(turns): points.append([0,i*arc_length,0]) cmd="-_Polyline" for i in range(len(points)): cmd += " {},{},{} Mode=Arc".format(0,points[i][1],0) cmd+=" _Enter" rs.Command(cmd) #move some points of the line up a bit to create a 3d walkway line=rs.FirstObject() rs.RebuildCurve(line,degree=3,point_count=turns*3) #rebuild curve with enough points to replicate the curve if three_dim==1: rs.EnableObjectGrips(line,enable=True) #you cannot move the object grips with the moveobject command, you have to reassign a whole set of new grips grips=rs.ObjectGripLocations(line) #list for grips for i in range(int(up_downs)): #do this as many times as up_downs is set index=ran.choice(range(1,len(grips)-1)) #index for grips (random choice), except for the first and the last point ran1=ran.uniform(0,100) if ran1max_diameter: #check if total diameter exceeds max diameter arc_radius=max_diameter/2 #if it does, make it smaller c_points=[] cur_angle=0 #angle starts at zero for i in range(p_num): next_point=rs.VectorRotate([arc_radius,0,0],cur_angle,[0,0,1]) cur_angle=angle+cur_angle next_point=[next_point[0]+base_point[0],next_point[1]+base_point[1],next_point[2]+base_point[2]] c_points.append(next_point) c_points.append(c_points[0]) #close pattern by adding first point again as last point cmd="-_Polyline" for i in range(len(c_points)): cmd+= " {},{},{} Mode=Arc".format(c_points[i][0], c_points[i][1], c_points[i][2]) cmd+=" _Enter" rs.Command(cmd, False) curve=rs.FirstObject(False) return curve def create_dome_top(pt): #for creating the tiny detail on top of the dome, randomised outline with randomised radii of the circles lofts=[] #list for circles for lofting later radii=list(range(3,10)) pts=rs.DivideCurve(rs.AddLine(pt,[pt[0],pt[1],pt[2]+dome_top_hgt]),12) #divide curve for how many circles we need for i in range(len(pts)): if i==0: #add one very big radius circle lofts.append(rs.AddCircle(pts[i],dome_top_rad)) if ilen(pts)-3: #make the top thin lofts.append(rs.AddCircle(pts[i],0.01)) srf=rs.AddLoftSrf(lofts) rs.CapPlanarHoles(srf) rs.MoveObject(srf,[0,0,hgt]) return(srf) def dome(): domes=[] #list with domes pipe_obj_pav=[] #list with curves and arcs that get projected from above onto the surface decs=[] #decorational lines for dome decs_pip=[] #decorational lines that come out of the project function for i in range(len(inner_pts)-1): #make lines for the center of the pavilion arcs=[] #list with arcs for the sides #make lines connecting the points (3d) l1=rs.AddLine(inner_pts[i],outer_pts[i+1]) l2=rs.AddLine(inner_pts[i+1],outer_pts[i]) #make flat lines connecting the points (2d) fl_l1=rs.AddLine([inner_pts[i][0],inner_pts[i][1],0],[outer_pts[i+1][0],outer_pts[i+1][1],0]) #flat version of l1 fl_l2=rs.AddLine([inner_pts[i+1][0],inner_pts[i+1][1],0],[outer_pts[i][0],outer_pts[i][1],0]) #flat version of l2 #calculate arc points on the inner side of the dome arc_point_inner=rs.VectorDivide(rs.VectorAdd(inner_pts[i],inner_pts[i+1]),2) arc_point_inner[2]+=arc_hgt #calculate arc points on the outer side of the dome arc_point_outer=rs.VectorDivide(rs.VectorAdd(outer_pts[i],outer_pts[i+1]),2) arc_point_outer[2]+=arc_hgt #calculate arc points on the front side of the dome arc_point_front=rs.VectorDivide(rs.VectorAdd(inner_pts[i],outer_pts[i]),2) arc_point_front[2]+=arc_hgt #calculate arc points on the front side of the dome arc_point_back=rs.VectorDivide(rs.VectorAdd(inner_pts[i+1],outer_pts[i+1]),2) arc_point_back[2]+=arc_hgt #make arcs (structural) a1=rs.AddArc3Pt(inner_pts[i],inner_pts[i+1],arc_point_inner) #arc on the inner side of the bridge a2=rs.AddArc3Pt(outer_pts[i],outer_pts[i+1],arc_point_outer) #arc on the outer side of the bridge a3=rs.AddArc3Pt(inner_pts[i],outer_pts[i],arc_point_front) #arc on the front side of the bridge a4=rs.AddArc3Pt(inner_pts[i+1],outer_pts[i+1],arc_point_back) #arc on the back side of the bridge arcs.extend([a1,a2,a3,a4]) #find the middle of the pavillon on the floor point=rs.CurveCurveIntersection(fl_l1,fl_l2)[0][1] #middle of pavillon (on the floor) #find the 3d version of the middle intersect_line=rs.AddLine(point,[point[0],point[1],hgt*2+z_var_max]) #line from floor up crossing both l1 and l2 pt=rs.CurveCurveIntersection(intersect_line,l2)[0][1] #intersecting the vertical line with l2 to get the middle rs.DeleteObject(intersect_line) #make a line for the top point of the dome (before moving everything up) hgt_line=rs.AddLine([pt[0],pt[1],pt[2]+hgt],[pt[0],pt[1],pt[2]+hgt_dome]) top_dome=rs.CurvePoints(hgt_line)[-1] #upper most point of the dome create_dome_top(pt=top_dome) rs.DeleteObject(hgt_line) if ithreshold: #if the z value of the point exceeds the threshold: create the base for the big column (has to be aligned) create_big_column(line=inner1,pt=p) for p in outer_pts: #create big columns below for outer line if p[2]>threshold: create_big_column(line=inner2,pt=p) for i in range(len(outer_pts)-1): #create arcs for points that are high, also columns and bases if outer_pts[i][2]>threshold: midpoint=find_midpoint_on_crv(crv=inner2,pt1=outer_pts[i],pt2=outer_pts[i+1]) #find the middle between two points (so we can place the arc properly) rs.AddPoint(midpoint) if outer_pts[i+1][2]threshold: midpoint2=find_midpoint_on_crv(crv=inner1,pt1=inner_pts[i],pt2=inner_pts[i+1]) rs.AddPoint(midpoint2) if inner_pts[i+1][2]threshold: #add cylindric column at the base (below the bridge) cyl=rs.AddLine([pt[0],pt[1],0],[pt[0],pt[1],pt[2]-thick/2]) c1=rs.AddCircle(rs.CurveStartPoint(cyl),thick_col_max) c2=rs.AddCircle(rs.CurveEndPoint(cyl),thick_col_min) srf=rs.AddLoftSrf([c1,c2]) rs.CapPlanarHoles(srf) for i in range(len(pts)): if i==0: #create podest for start box=make_box(insertion=pts[i],xsize=pod_len,ysize=width,zsize=thick) rs.MoveObject(box,[-pod_len+0.25,-width+stripe,-thick]) dome() make_bridge() #layer for glass (everything else stays on default) if glass==1: rs.AddLayer("glass") rs.LayerColor("glass",(255,255,0)) rs.ObjectLayer(l_glass,"glass") #cleanup #delete all curves, points and duplicatese rs.Command("_SelCrv _Enter") rs.Command("_Selpt _Enter") rs.Command("_SelDup _Enter") rs.DeleteObjects(rs.SelectedObjects()) rs.EnableRedraw(True)