import rhinoscriptsyntax as rs import random as ran rs.DeleteObjects(rs.AllObjects()) #variablen lauf thick = 0.18 # lauf dicke hgt = 7 # ueberbrueckte hoehe # stiegenparameter s_width = 3 # s_width = stiegen Breite pod_l = 1.8 # pod_l = podest tiefe tt = 0.3 # stufen tiefe th = 0.17 # standard stufensteigung thmax = 0.19 # maximale steigung def make_curved_podeststair(curve, th=th, tt=tt, steps=40, thick=thick, s_width=s_width, pod_l=s_width/2, DC=48, P=12, A=0): pts = [[0,0,0]] for i in range(1,steps): #switch=ran.randint(0,9) if(not(i%DC)): ##DC: richtungs aenderung? th=-th pts.append([pts[-1][0]+pod_l,pts[-1][1],pts[-1][2]]) pts.append(pts[-1]) pts.append((pts[-1][0]+tt,pts[-1][1],pts[-1][2])) elif(not(i%P)): ##P: Podest pts.append((pts[-1][0]+pod_l,pts[-1][1],pts[-1][2])) pts.append((pts[-1][0]+tt,pts[-1][1],pts[-1][2])) elif(i==1) and (A>0): pts.append([pts[-1][0]+A,pts[-1][1],pts[-1][2]]) pts.append([pts[-1][0],pts[-1][1],pts[-1][2]+th]) pts.append([pts[-1][0]+tt,pts[-1][1],pts[-1][2]]) else: ##normale stufen pts.append([pts[-1][0],pts[-1][1],pts[-1][2]+th]) pts.append([pts[-1][0]+tt,pts[-1][1],pts[-1][2]]) if th<0: ## unterer kanten punkt stiegen abtritt pts.append([pts[-1][0],pts[-1][1],pts[-1][2]+th]) return_list = [] for i in range(-1,-len(pts),-2): return_list.append((pts[i][0], pts[i][1], pts[i][2]-thick)) pts.extend(return_list) pts.append([pts[0][0], pts[0][1], pts[0][2]-thick]) pts.append(pts[0]) s_outline = rs.AddPolyline(pts) path = rs.AddLine(pts[0],[pts[0][0], pts[0][1]+s_width/2, pts[0][2]]) shadow = rs.AddLine(pts[0],[return_list[0][0], return_list[0][1], pts[0][2]]) s_surf = rs.AddPlanarSrf(s_outline) rs.Command("_Flow _selID {} _Enter _selID {} _selID {} _Enter".format(s_surf[0], shadow, curve), False) profile = rs.FirstObject() stair = rs.OffsetSurface(profile, s_width/4, both_sides=True, create_solid=True) rs.DeleteObjects([s_surf[0], shadow, curve, path, s_outline, profile]) return(stair) """ def make_random_curve(p_num, range_x=20, range_y=25, degree=3): c_points =[] for i in range(p_num): c_points.append([ran.uniform(0,range_x), ran.uniform(0,range_y), 0]) c_points.sort() curve = rs.AddCurve(c_points, degree) return(curve) """ #Kleeblatt form als polylinie aus boegen basiert auf jeweiligen winkel ohne durchdringen eigener linie def make_clover(p_num, radius=2, angle=50, translation=[0,0,0]): c_points =[] cur_angle=0 for i in range(p_num): nextpoint = rs.VectorRotate([radius,0,0],cur_angle, [0,0,1]) cur_angle=angle+cur_angle c_points.append(nextpoint) 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]+i*0.0000001)# hack to prevent short-circuiting cmd +=" _Enter" rs.Command(cmd, False) curve=rs.FirstObject(False) rs.Command("-_ProjectToCPlane _selID {} _Enter _Yes _Enter".format(curve), False)# project curve to Cplane rs.MoveObject(curve, translation) return(curve) rs.EnableRedraw(False) #definieren der kleeblatt form if 1: curve = make_clover(12, 3, 60, (0,-30,0)) stair = make_curved_podeststair(curve, th=th,tt=tt, steps=200, pod_l=pod_l, thick=thick, s_width=s_width, DC=30, P=30, A=2.0) rs.EnableRedraw(True)