From 47ab065387d9113a01e7795db7b790987c1d2aa0 Mon Sep 17 00:00:00 2001 From: lertlmaier Date: Tue, 10 Jun 2025 09:51:00 +0200 Subject: [PATCH] =?UTF-8?q?Zeile=20mit=20=C3=BCberpr=C3=BCfung=20ob=20pos?= =?UTF-8?q?=20in=20ld=20steht=20auskommentiert.=20Sonst=20wird=20kein=20me?= =?UTF-8?q?rge=20der=20dicts=20ausgef=C3=BCrt=20und=20artikelnummer=20des?= =?UTF-8?q?=20sensors=20aus=20anderem=20INSERT=20findet=20den=20weg=20nich?= =?UTF-8?q?t=20in=20allSensors=20da=20kein=20pos=20eintrag=20dort=20vorhan?= =?UTF-8?q?den?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/getpositions.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/getpositions.py b/lib/getpositions.py index 77774f6..213ca64 100644 --- a/lib/getpositions.py +++ b/lib/getpositions.py @@ -48,7 +48,6 @@ def get_type_of_name(name): DropKeys = [ "FC", # Motorschutzschalter "PF", # Leuchtmelder - "SF", "DI", # Feedback vom Gerät "QA", # Hauptschütz "SF" # Drucktaster @@ -115,6 +114,8 @@ def get_input_positions(msp: ezdxf.document.Drawing.modelspace)-> tuple: """ allSensors = dict() allCables = dict() + allunknowns = dict() + allSchaltschrank = dict() # Über alle Blockreferenzen (INSERT) im Modelspace laufen for insert in msp.query('INSERT'): @@ -124,23 +125,25 @@ def get_input_positions(msp: ezdxf.document.Drawing.modelspace)-> tuple: ld, id, typ = get_attributes_of_insert(insert) - # Nur wenn eine ID vorhanden ist, und eine gültige Position existiert + # Verarbeite je nach Typ if typ == "Sensor": if id and "pos" in ld and isinstance(ld["pos"], tuple) and len(ld["pos"]) == 2: if id in allSensors: - allSensors[id] = merge_two_dicts(allSensors[id], ld) #Kombiniert alle infos aus dxf und "pos" + allSensors[id] = merge_two_dicts(allSensors[id], ld) else: allSensors[id] = ld elif typ == "Kabel": allCables[id] = ld + elif typ == "Schaltschrankelement": + allSchaltschrank[id] = ld else: - # Falls das Objekt ein Teil des Schaltschranks o.ä ist, dann nichts merken - pass + allunknowns[id] = ld + return allSensors, allCables def get_input_positions_iter(dxf_path) -> tuple: """ - Iterative Version für große DXF-Dateien mit iterdxf (kein Context Manager!). + Iterative Version für große DXF-Dateien mit iterdxf """ allSensors = dict() allCables = dict() @@ -155,18 +158,17 @@ def get_input_positions_iter(dxf_path) -> tuple: # Nur wenn eine ID vorhanden ist, und eine gültige Position existiert if typ == "Sensor": - if id and "pos" in ld and isinstance(ld["pos"], tuple) and len(ld["pos"]) == 2: - if id in allSensors: - allSensors[id] = merge_two_dicts(allSensors[id], ld) #Kombiniert alle infos aus dxf und "pos" - else: - allSensors[id] = ld + #if id and "pos" in ld and isinstance(ld["pos"], tuple) and len(ld["pos"]) == 2: + if id in allSensors: + allSensors[id] = merge_two_dicts(allSensors[id], ld) #Kombiniert alle infos aus dxf und "pos" + else: + allSensors[id] = ld elif typ == "Kabel": allCables[id] = ld elif typ == "Schaltschrankelement": allSchaltschrank[id] = ld else: allunknowns[id] = ld - # Falls das Objekt ein Teil des Schaltschranks o.ä ist, dann nichts merken return allSensors, allCables @@ -447,14 +449,14 @@ if __name__ == '__main__': filename = args.filename (dxf_path, dexists) = check_file_in_work(work_dir, filename) - - zeitanfang = time.time() if dxf_is_binary(dxf_path): # Wenn dxf eine binary ist, dann komplett parsen und modelspace anlegen doc = get_dxf_file(dxf_path) + print("Given .dxf-file is binary dxf. Proceeding to read file. Watch RAM-usage.") msp = doc.modelspace() use_iter = False else: + print("Given .dxf-file is ASCII-dxf. Proceeding to user iterative functions. Process may take longer.") use_iter = True res_sens = dict() @@ -530,8 +532,6 @@ if __name__ == '__main__': res_not_found = check_existance(res_mappings, res_dist, res_sens) output_results["not_found"] = res_not_found write_results(to_json(output_results), work_dir, f"{basename}.json") - zeitende = time.time() - print(zeitende-zeitanfang) else: parser.print_help()