############################# ### DUMPS Alexander ### ### ### ############################# ############################## import rhinoscriptsyntax as rs import random, time, sys, os, time ### sys.path.append("P:/WWW/adarch") ### import DM_lib as dm ### reload(dm) import DM_osm as osm ### ############################## reload (osm) dm.eA() ############################## 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 ! ####################### ##OSMpath = "D:/OSM/osmData/" OSMpath = "P:/WWW/adarch/dm2/ue_07/" ####################### OSMfile = "map.osm" #OSMfile = "ellmauer_halt.osm" #OSMfile = "weissensee.osm" #OSMfile = "kibo.osm" #OSMfile = "paris_sorbonne.osm" #OSMfile = "karlsplatz.osm" #OSMfile = "madison_square.osm" #OSMfile = "NYC_sankt_marks.osm" #OSMfile = "urania.osm" #OSMfile = "urania_00.osm" #OSMfile = "kiew.osm" #OSMfile = "EmpStat.osm" #OSMfile = "stockholm.osm" #OSMfile = "lampedusa.osm" ############################## # osm.eAA() # erase absolutely all objects, even hidden & locked #osm.OSMi(OSMfile, OSMpath, move2Guinea=1) osm.OSMi(OSMfile, OSMpath, trimBounds=1, do3D=1, minHeight=1.0, heightFac=1.0, randomize=[5.0, 10.0], doAllCurves=1, move2Guinea = 1, verbose=0) #################################### rs.CurrentLayer("Default") rs.ViewDisplayMode(None, "ghosted") #OSM ENDE #Schiff Anfang ############### #Import file_path = "C:/Users/alexd/Desktop/BoaPunkt2.txt" ###Opt.### ###path fuer Punkte von Modell def import_points_from_file(file_path): ###Import von den Punkten try: file = open(file_path, 'r') ###oeffnet file lines = file.readlines() ###lest file file.close() ###schliesst file points = [] ###leere Pointliste von audi for i, line in enumerate(lines): ###fuer jede line in path file if i % 1 == 0: ####wieviele punkte von 47000 genutzt werden. zB i % 10 = jedes 10., daher 4700 point_data = line.strip().split(',') ###splittet jede einzelne line. Daher keine ungueltigen lines if len(point_data) == 3: ###wenn line 3 daten beinhaltet (Koordinaten) try: ###dann versuche x = float(point_data[0]) ###x = erste data von line y = float(point_data[1]) ###y = zweite data von line z = float(point_data[2]) -7 ###z = dritte data von line. -7 weil basismodell bisschen ueber Boden liegt audi_pnts = rs.AddPoint(x, y, z) ###addpoint fuer jede line in pathfile points.append(audi_pnts) ###schliesst audi_pnts an leere points liste an except: print("Invalid line: " + line) ###wenn eine line nicht funktioniert - fehlermeldung else: print("Invalid line: " + line) ### wenn line nicht aus 3 daten besteht - fehlermeldung return points ### returns points aus der def import... except: print("Error reading file!") ###wenn path file nicht gefunden wird - fehlermeldung ## ChatGPT def controlpoints(): ###definition von Punkten welche Platzierung und Rotation kontrollieren pnts = [] ctrl_pnt = rs.AddPoint(50847.3,51387.2,0) ###Kontrollpunkt der Platzierung in der Mitte der Vorderachse - Momentan durch globale Koordinaten definiert ctrl_crv_end = rs.AddPoint(50847.3,51387.2,0) ###Endkontrollpunkt der Rotation in Fahrtrichtung - Momentan durch globale Koordinaten definiert pnts.append(ctrl_pnt) ###schliesst Kontrollpunkt Platzierung an leere pnts liste an pnts.append(ctrl_crv_end) ###schliesst Kontrollpunkt Rotation an leere pnts liste an return pnts ###returns pnts aus def controllpoints boat = import_points_from_file(file_path) ###Variable "boat" fuer NUR Modell des Autos ctrl_pnts = controlpoints() ###Variable "ctrl_pnts fuer NUR Kontrollpunkte (Vorderachse und Fahrtrichtung audi = boat + ctrl_pnts ###Variable "audi" fuer gesamtes model + Kontrollpunkte cp = ctrl_pnts[0] ###Variable cp fuer Kontrollpunkt Platzierung cc_end = ctrl_pnts[1] ###Kontrollpunkt fuer Vektor der Rotation (Vektor schneidet naechsten Strassenpunkt -> Daher driftet #boat_mo = rs.MoveObjects(boat[0:20000],(50847,51387,0)) boat_moend = rs.RotateObjects(boat,(50847,51387,0),90,(2,3,0),0) ############################################### file_path2 = "C:/Users/alexd/Desktop/3dOBj.txt" ###path fuer Punkte von Modell #def import_text_from_file(file_path): # try: # # # with open(file_path, 'r') as file: # lines = file.readlines() # Ltei # # # En # bldgNames = [] # # # Verei # for line in lines: # # Entfern Kommas # point_data = line.strip().split(',') # # # if len(point_data) == 3: # # # bldgNames.append(tuple(map(float, point_data))) # # return bldgNames # return [] #ChatGPT #bldgNames = import_text_from_file(file_path2) bldgNames = ["_bldg3D_higBy_ran_264445287","_bldg3D_higBy_ran_264445286","_bldg3D_higBy_ran_265985741","_bldg3D_higBy_ran_264392058","_bldg3D_higBy_ran_264392057","_bldg3D_higBy_ran_266059720","_bldg3D_higBy_ran_266059718","_bldg3D_higBy_ran_266059717","_bldg3D_higBy_ran_266059716","_bldg3D_higBy_ran_263927131","_bldg3D_higBy_ran_263589346","_bldg3D_higBy_ran_264389410","_bldg3D_higBy_ran_263834268","_bldg3D_higBy_ran_264060816","_bldg3D_higBy_ran_263591196","_bldg3D_higBy_ran_263579555","_bldg3D_higBy_ran_264388860","_bldg3D_higBy_ran_263655636","_bldg3D_higBy_ran_198299414","_bldg3D_higBy_ran_263590676","_bldg3D_higBy_ran_264390761","_bldg3D_higBy_ran_263576436","_bldg3D_higBy_ran_263587957","_bldg3D_higBy_ran_264346119","_bldg3D_higBy_ran_263982807"] bldgIDs = [ rs.ObjectsByName(namX)[0] for namX in bldgNames ] mitteGeb = [] mitteGebhoch = [] for bldg in bldgIDs: coords = dm.getSurfacePoints(bldg) center = dm.pntCentroid(coords) mitteGeb.append(center) centerhoch = rs.VectorAdd(center, [0,0,2]) mitteGebhoch.append(centerhoch) rs.AddLine(center, centerhoch) #main_center = dm.pntCentroid(mitteGebhoch) main_center = dm.pnt2cor(mitteGebhoch) ########################################## coords1 = sorted(boat_moend, key=lambda sKey: rs.PointCoordinates(sKey)[2]) max1 = coords1[-1]#[2] rs.AddPoint(max1) #crv = rs.AddCurve((max1)+ mitteGeb,1) max1_coords = rs.PointCoordinates(max1) all_points = [max1_coords] + mitteGebhoch for i in range(len(mitteGebhoch)): start_point = max1 end_point = mitteGebhoch[i] rs.AddLine(start_point, end_point)