#* 1) generate an exiting curve, looping the UN_headquaters and its neighbourhood #* 2) try to create some support_structure # connect your construct to the facade of the UN_slab and/or the "unoBaseCrv" and/or to some edges or vertices of nearby buildings # import one of the "unitednations_osm_*.3dm" files to get some sourroundings and background ################################### ### DM2_w24 # AGruber@tugraz.at ### ### ue_05 UN_headquaters NYC ### ################################### ############################## import rhinoscriptsyntax as rs import random, time, sys ### sys.path.append("C:/Users/frede/Desktop/dm2/lib") ### import DM_lib as dm ### reload(dm) ############################## rs.UnitSystem(4) # km = 5, meters = 4, cm = 3 etc rs.ShowGrid(None, 0) # grid > 0 = off rs.ShowGridAxes(None, 1) # y/y/z axen display > 0/1 = off/on rs.ViewDisplayMode(rs.CurrentView(), "wireframe") rs.Command("cplane w t enter", 0) # cPlane World Top dm.PointRadius(displayModeX=0, rad=3, styl=3) dm.printDisplay(state=1) ### nomen est omen / printDisplay(state=1, scale=1000, thickness=1, color="Display") rs.EnableRedraw(0) ### MAC >> problem ! ###_________________________________________# ### basic settings for grid to fit UN_slab # ### # ! no need 2 change ! floors = H = dm.H = 40 # default=40 / incl roof slabs = L = dm.L = 11 # default=11 depth = D = dm.D = 4 # default= 4 / division in building_depth floorHeight = fH = dm.fH = 4.0 # default= 4.0 / 4.0*(H-1) = 156 meters # ############# # get gridCoords L*D*H = 1760 #UnoGridCoords = dm.getUnoGridCoords() # get from DM_lib as dm #################___________________________# # for coord in UnoGridCoords: print(coord) dm.newEmptyLayer("UNO::setUp::points", [150,150,200] ) dm.newEmptyLayer("UNO::setUp::geo", [150, 20,150] ) dm.newEmptyLayer("UNO::setUp::crv", [200, 100, 100]) dm.newEmptyLayer("UNO::setUp", [120,120,140] ) ################ lengthVec = lVec = rs.VectorUnitize(rs.VectorSubtract( dm.getUnoCoord(0, 0, 0), dm.getUnoCoord(1, 0, 0) )) ## rs.AddPoint( dm.getUnoCoord(1, 0, 0) ) depthVec = dVec = rs.VectorUnitize(rs.VectorSubtract( dm.getUnoCoord(0, 1, 0), dm.getUnoCoord(0, 0, 0) )) ## rs.AddPoint( dm.getUnoCoord(0, 1, 0) ) ################ # PROGRAM: ## #for i, coord in enumerate(UnoGridCoords): # # print str(i) + ". ", coord # if i//44 < 1: # rs.AddTextDot("DOT" + str(i), coord) def buildUN(showPoints=True, showSlabs=False): UnoGridCoords = dm.getUnoGridCoords() # Draw Top and Base Curves baseUNCurveCoords = [dm.getUnoCoord( 0, 0, 0), dm.getUnoCoord( 10, 0, 0), dm.getUnoCoord( 10, 3, 0), dm.getUnoCoord( 0, 3, 0), dm.getUnoCoord( 0, 0, 0),] topUNCurveCoords = [dm.getUnoCoord( 0, 0, 39), dm.getUnoCoord( 10, 0, 39), dm.getUnoCoord( 10, 3, 39), dm.getUnoCoord( 0, 3, 39), dm.getUnoCoord( 0, 0, 39),] baseUNCurve = rs.AddCurve(baseUNCurveCoords, 1) topUNCurve = rs.AddCurve(topUNCurveCoords, 1) # layer_name = "TestThickness" # rs.AddLayer(layer_name, color=(255, 0, 0), visible=True) # rs.LayerPrintWidth(layer_name, .75) # Set print width in millimeters # rs.ObjectLayer(baseUNCurve, layer_name) rs.ObjectColor(baseUNCurve, [0, 0, 0]) rs.ObjectColor(topUNCurve, [0, 0, 0]) # Draw All Points if showPoints: rs.AddPoints(UnoGridCoords) # Show slabs if showSlabs: dm.UN_slab(showAll=True) return UnoGridCoords, baseUNCurve, topUNCurve def drawTube(minimalCurveDistanceFromUN=50, surplusCurveDistanceFromUN=0, tubeBodyCurvesQuantity=16, tubeRadius=5.5): # minimalCurveDistanceFromUN - the minimal distance on which the points of a curve will be situated # surplusCurveDistanceFromUN - the additional fluctuating distance of points of a curve # Draw a Central Curve: points of a curve path # Setup vectors for moving coordinates lengthVec = rs.VectorUnitize(rs.VectorSubtract( dm.getUnoCoord(0, 0, 0), dm.getUnoCoord(1, 0, 0) )) depthVec = rs.VectorUnitize(rs.VectorSubtract( dm.getUnoCoord(0, 1, 0), dm.getUnoCoord(0, 0, 0) )) # Starting point of the Curve # p0 is the 1st point of a 3rd row of the 3th floor p0 = dm.getUnoCoord(0, 2, 2) # p1 is p0 moved away from the UN HQ by 75 p1 = rs.VectorAdd(p0, rs.VectorScale( lengthVec, 75.0 ) ) # Ending point of the Curve # pX is the 11th point of a 2nd row of the 39th floor pX0 = dm.getUnoCoord(10, 1, 38) pX1 = rs.VectorAdd(pX0, rs.VectorScale( lengthVec, -25.0 ) ) centralCurveCoordinates = [p0, p1] # Setup first 2 points counter = 0 for h in range(0, H-1, 4): # step 4 so that it is easily connects with the end counter = counter+1 if counter%4 == 1: nextCurvePoint = rs.VectorAdd( dm.getUnoCoord( int((L-1)/2), 0, h ), rs.VectorScale(depthVec, random.uniform(minimalCurveDistanceFromUN, minimalCurveDistanceFromUN+surplusCurveDistanceFromUN)) ) elif counter%4 == 2: nextCurvePoint = rs.VectorAdd( dm.getUnoCoord( L-1, int((D-1)/2), h ), rs.VectorScale(lengthVec, random.uniform(minimalCurveDistanceFromUN, minimalCurveDistanceFromUN+surplusCurveDistanceFromUN)*-1) ) elif counter%4 == 3: nextCurvePoint = rs.VectorAdd( dm.getUnoCoord( int((L-1)/2), D-1, h ), rs.VectorScale(depthVec, random.uniform(minimalCurveDistanceFromUN, minimalCurveDistanceFromUN+surplusCurveDistanceFromUN)*-1) ) elif counter%4 == 0: nextCurvePoint = rs.VectorAdd( dm.getUnoCoord( 0, int((D-1)/2), h ), rs.VectorScale(lengthVec, random.uniform(minimalCurveDistanceFromUN, minimalCurveDistanceFromUN+surplusCurveDistanceFromUN)) ) centralCurveCoordinates.append(nextCurvePoint) # Add two last points centralCurveCoordinates.append(pX1) centralCurveCoordinates.append(pX0) print len(centralCurveCoordinates)-4 centralCurve = rs.AddCurve( centralCurveCoordinates, 2 ) rs.ObjectColor(centralCurve, [150, 0, 0]) # Draw a Tube: number of divisions of a Central Curve, number of curves to draw a Tube centralCurveDividedCoordinates = rs.DivideCurve(centralCurve, 500) circlesCoordinates = [] # coordinates for circles # We need to ues coordinates from division, so that our tube is built exactly around centralCurve for coordinate in centralCurveDividedCoordinates: parameterX = rs.CurveClosestPoint( centralCurve, coordinate ) # Returns parameter of the point on a curve that is closest to a test point. planeX = rs.CurvePerpFrame( centralCurve, parameterX ) # Returns the perpendicular plane at a parameter of a curve. The result is relatively parallel (zero-twisting) plane circle = rs.AddCircle( planeX, tubeRadius) # AddCircle(plane_or_center, radius) circleCoordinates = rs.DivideCurve( circle, tubeBodyCurvesQuantity, 0) rs.DeleteObject( circle ) circlesCoordinates.append( circleCoordinates ) circlesQuantity = len(circlesCoordinates) # Drawing Tube's Body for i in range(tubeBodyCurvesQuantity): tubeBodyCurveCoordinates = [] for j in range(circlesQuantity): tubeBodyCurveCoordinates.append( circlesCoordinates[j][i] ) rs.ObjectColor(rs.AddCurve(tubeBodyCurveCoordinates, 2), [150, 150, 0]) return centralCurve def drawSupportStructure(centralCurve, centralCurveDivisions, supportStructureCurve, supportColor=[50,50,50]): domain = rs.CurveDomain(centralCurve)[1] # Returns the domain of a curve object as an indexable object with two elements. # DRAWING A SUPPORT STRUCTURE? for p in range(0, centralCurveDivisions+1): fraction = p/centralCurveDivisions # factor? percent? # print dom*fac centralCurveCoordinate = rs.EvaluateCurve( centralCurve, domain*fraction ) ## para = dom*fac ! # Evaluates a curve at a parameter and returns a 3D point parameter = rs.CurveClosestPoint(supportStructureCurve, centralCurveCoordinate) supportStructureCoordinate = rs.EvaluateCurve( supportStructureCurve, parameter ) supportCurve = rs.AddCurve( [centralCurveCoordinate, supportStructureCoordinate ] ) # ADDING THE SUPPORT STRUCTURE rs.ObjectColor(supportCurve, supportColor) def drawTextDotsForEachUNPoint(): tmpH = 0 tmpD = 0 tmpL = 0 for i, coord in enumerate(UnoGridCoords): rs.AddTextDot(str(tmpH) + "; " + str(tmpD) + "; " + str(tmpL), coord) tmpH += 1 if (i+1)%11 == 0: tmpD += 1 tmpH = 0 if (i+1)%44 == 0: tmpL += 1 tmpH = 0 tmpD = 0 if 1: UnoGridCoords, baseUNCurve, topUNCurve = buildUN(showSlabs=False) centralCurve = drawTube( minimalCurveDistanceFromUN=50, surplusCurveDistanceFromUN=50, tubeBodyCurvesQuantity=64, tubeRadius=5) drawSupportStructure(centralCurve, 100, baseUNCurve, supportColor=[120, 50, 43]) # drawTextDotsForEachUNPoint()