import rhinoscriptsyntax as rs import math rs.DeleteObjects(rs.AllObjects()) rs.EnableRedraw(False) #### VARIABLEN #### radius1 = 50 #### EINZELTEILE #### ## Plattform ## plane = [0, 0, 0] points = [plane, [radius1/5, radius1/5, 0], [2/3*radius1, radius1/5, 0], [4/5*radius1, 0, 0], [radius1*2, 0, 0], [radius1*2.5, radius1*-1/5, 0], [radius1*2.5, radius1*-2/5, 0], [radius1*3, radius1*-3/5, 0], [radius1*3, -radius1, 0]] PlaLiHa = rs.AddPolyline(points) #PlaLiHa = Plattform Linie Haelfte PlaLiHa2 = rs.MirrorObject(PlaLiHa, [120, -radius1, 0], [0, -radius1, 0], True) planeA = [0,-radius1,0] degree = -180 PlaLi3 = rs.AddArc(planeA, radius1, degree) PlaLiV = rs.RotateObject(PlaLi3, [0,-radius1,0],90) PlaCrv = rs.JoinCurves([PlaLiHa, PlaLiHa2, PlaLiV]) # PlaCrv = Plattform Curve rs.DeleteObjects([PlaLiHa, PlaLiHa2, PlaLiV]) if rs.IsCurveClosed(PlaCrv): PlaSrf = rs.AddPlanarSrf(PlaCrv) di = 2 PlaDi = rs.AddLine([0, 0, 0], [0, 0, di]) # PlaDi = Plattform Dicke Pla = rs.ExtrudeSurface(PlaSrf[0], PlaDi) # Pla = fertige Plattform rs.DeleteObjects([PlaDi, PlaSrf]) MPla = rs.MoveObject(Pla, [radius1 / 2, radius1, 0]) # MPla = Plattform geMoved ## Gelaender ## GeDi = 4.5 # Gelaender Dicke GeHo = 7 # Gelaender Hoehe GeCrv = rs.OffsetCurve(PlaCrv, [10, 0, 0], GeDi) GePath = rs.AddLine([0, 0, 0], [0, 0, GeHo]) CRVS = [PlaCrv, GeCrv] extrusions = [] for crv in CRVS: extrusion = rs.ExtrudeCurve(crv, GePath) if extrusion: rs.CapPlanarHoles(extrusion) extrusions.append(extrusion) if len(extrusions) == 2: result = rs.BooleanDifference(extrusions[0], extrusions[1]) if result: rs.DeleteObjects(extrusions) rs.DeleteObjects([ GeCrv, GePath]) MGe = rs.MoveObject(result, [0, radius1, di]) ## Block ## height = 500 dichte = 50 #je niedriger, desto weniger abstand zwischen Plattformen segments = height/dichte x = 1 y = 1 zB = height / segments - di corners2 = [[0, 0, 0], [x, 0, 0], [x, y, 0], [0, y, 0], [0, 0, zB], [x, 0, zB], [x, y, zB], [0, y, zB]] plane = [0,0,0] ReWidth = radius1 * 3/5 ReHeight = radius1 boxLi = rs.AddRectangle(plane, ReWidth, ReHeight) boxLiSe = 30 #maximale Anzahl my_pts = rs.DivideCurve(boxLi, boxLiSe, False, False) #### SPIRALE #### point0 = [0, 0, 0] point1 = [0, 0, 1] height = 500 div = 4 #Division - fuer Anpassung der Hoehe an die Turns turns = 1/div radius0 = radius1 spiral = rs.AddSpiral(point0, point1, height*div, turns, radius0, radius1) dichte = 50 #je niedriger, desto weniger abstand zwischen Plattformen segments = height/dichte pts = rs.DivideCurve(spiral, segments, False, True) tangents = [rs.CurveTangent(spiral, rs.CurveClosestPoint(spiral, p)) for p in pts] rs.DeleteObject(spiral) #### ARRANGE AND ROTATE #### ## plattform ## gedrehtes = [] rs.MoveObject(MPla, [-radius1/2, radius1, 0]) for i, (p, tangent) in enumerate(zip(pts[:-1], tangents[:-1])): CoPla = rs.CopyObject(MPla, p) angle = math.degrees(math.atan2(tangent[1], tangent[0])) RoCoPla = rs.RotateObject(CoPla, p, angle, [0, 0, 1]) gedrehtes.append(RoCoPla) rs.DeleteObject(MPla) #### ARRANGE AND ROTATE AND SCALE #### ## gelaender ## rs.MoveObject(MGe, [0, radius1, di]) for i, (p, tangent) in enumerate(zip(pts[:-1], tangents[:-1])): scale_factor = -1 CoGe = rs.CopyObject(MGe, p) angle = math.degrees(math.atan2(tangent[1], tangent[0])) RoCoGe = rs.RotateObject(CoGe, p, angle, [0, 0, 1]) gedrehtes.append(RoCoGe) scafa = 1 - (p[2] / height) * scale_factor ScaCoGe = rs.ScaleObject(CoGe, p, [1, 1, scafa]) gedrehtes.append(ScaCoGe) bbox = rs.BoundingBox(CoGe) if bbox: z_shift = bbox[0][2] - p[2] MCoGe2 = rs.MoveObject(CoGe, [0, 0, -z_shift+di]) gedrehtes.append(MCoGe2) rs.DeleteObject(MGe) #### ARRANGE AND ROTATE #### ## box ## # rectangles # StDif = 20 # Stuetzen Differenz oben unten translation = [radius1 * 1.3, radius1 * 0.5, di] MStu = rs.MoveObjects(boxLi, translation) created_points = [] for i, (p, tangent) in enumerate(zip(pts[:-1], tangents[:-1])): CoStu = rs.CopyObjects(boxLi, p) angle = math.degrees(math.atan2(tangent[1], tangent[0])) rs.RotateObject(CoStu, p, angle, [0, 0, 1]) for obj in CoStu: bbox = rs.BoundingBox(CoStu) if bbox: max_z = max(pt[2] for pt in bbox) if max_z > height / 2: division_points = rs.DivideCurve(CoStu, boxLiSe - StDif, False) for point in division_points: ptz = rs.AddPoint(point) created_points.append(ptz) boxz = rs.AddBox(corners2) StuFerU = rs.MoveObjects(boxz, ptz) gedrehtes.append(StuFerU) else: division_points = rs.DivideCurve(CoStu, boxLiSe, False) for point in division_points: ptz = rs.AddPoint(point) created_points.append(ptz) boxz = rs.AddBox(corners2) StuFerO = rs.MoveObjects(boxz, ptz) gedrehtes.append(StuFerO) rs.DeleteObjects(CoStu) for ptz in created_points: rs.DeleteObject(ptz) rs.DeleteObject(MStu) ####COPY#### ged2 = rs.CopyObjects(gedrehtes, None) gedrehtesGedreht = rs.RotateObjects(ged2, [0,0,0], 180, False) #### ZYLINDER #### plane = [0, 0, 0] hoehe = height top_plane = [0, 0, hoehe] radius = radius0 cir = rs.AddCircle(plane, radius) x = 2 y = x z = height cornersC = [[0, 0, 0], [x, 0, 0], [x, y, 0], [0, y, 0], [0, 0, z], [x, 0, z], [x, y, z], [0, y, z]] cirOff = rs.AddCircle(plane, radius-x) cirP = 20 #Kreis Punkte cirPts = rs.DivideCurve(cirOff,cirP, False ,True) for p in cirPts: cirB = rs.AddBox(cornersC) StZ = rs.MoveObjects(cirB, p) rs.DeleteObject(cirOff) ## oben Dach ## top_circle = rs.AddCircle(top_plane, radius) D = 10 top_path = rs.AddLine([0, 0, hoehe], [0, 0, hoehe + D]) top_surface = rs.ExtrudeCurve(top_circle, top_path) topSurf2 = rs.CapPlanarHoles(top_surface) crvs = {cir, top_circle} rs.DeleteObjects(crvs) DecPos = [0,0,hoehe] #Deckel Position DCrv = rs.MoveObject(PlaCrv, DecPos) MDCrv = rs.MoveObject(DCrv, [0, radius1, 0]) DDi = D DPath = rs.AddLine([radius1/2,radius1,hoehe], [radius1/2,radius1,hoehe+DDi]) DEx = rs.ExtrudeCurve(MDCrv, DPath) rs.IsCurveClosed(MDCrv) DSrf = rs.AddPlanarSrf(MDCrv) DSrf2 = rs.CopyObject(DSrf, [0,0,DDi]) rs.DeleteObject(MDCrv) D2 = rs.MirrorObjects([DSrf, DSrf2, DEx],[0,0,hoehe],[0,1,hoehe],True) ####STAIRS#### radiusS = radius1 - radius1/3 turnsS = 9 spiralS = rs.AddSpiral([0,0,0],[0,0,hoehe-zB],hoehe/turnsS, turnsS, radiusS) Sh = 1.7 segmentsS = hoehe / Sh / turns / 1.45 ptsS = rs.DivideCurve(spiralS, segmentsS, False, True) x=10 y=2.9 z=Sh cornersS = [[0, 0, 0], [x, 0, 0], [x, y, 0], [0, y, 0], [0, 0, z], [x, 0, z], [x, y, z], [0, y, z]] for i, p in enumerate(ptsS): StairS = rs.AddBox(cornersS) rs.MoveObjects(StairS, p) rot = i / float(segmentsS) angle = rot * 2 * math.pi * turnsS stepsS = rs.RotateObject(StairS, p, math.degrees(angle), [0, 0, 1]) rs.DeleteObject(spiralS)