diff --git a/Lisp/export.lsp b/Lisp/export.lsp index d6b8f36..cc60bb1 100644 --- a/Lisp/export.lsp +++ b/Lisp/export.lsp @@ -140,13 +140,9 @@ ;; csv-name = Ergebnis-CSV-Name (z.B. "export.csv") (defun csv:run-export (label py-name csv-name / ss i ename fh out-pfad py-skript ergebnis-pfad cmd first-block count) - ;; Vor dem Export: Doppelte IDs pruefen und korrigieren - (if (atoms-family 1 '("ssg-id-check-all")) - (progn - (princ (strcat "\n[" label "] Pruefe IDs auf Duplikate...")) - (ssg-id-check-all) - ) - ) + ;; Vor dem Export: IDs aller Bloecke sicherstellen und Duplikate korrigieren + (princ (strcat "\n[" label "] Pruefe und vergebe IDs...")) + (ssg-id-check-all) ;; Vor dem Export HOEHE/DREHUNG aller Omniflo-Elemente aktualisieren (princ (strcat "\n[" label "] Aktualisiere Hoehe/Drehung...")) (omni:update-all-attribs) @@ -351,17 +347,6 @@ ) -;; --- CSV-Zeile fuer ein Omniflo-Element bauen --- -(defun csv:omni-csv-line (elem-nr teileart bezeichnung merkmale-json) - (strcat (itoa elem-nr) - ";\"" teileart "\"" - ";\"shape_" (substr (rtos (* (getvar "CDATE") 1000000.0) 2 0) 1 8) - (substr (rtos (* (getvar "TDUSRTIMER") 1000000.0) 2 0) 1 8) "\"" - ";\"" bezeichnung "\"" - ";1" - ";" merkmale-json) -) - ;; ============================================================ ;; C:OMNI_EXPORT - Omniflo-Elemente zaehlen und als CSV exportieren @@ -373,6 +358,9 @@ len-ap110 len-ap60 laenge-str fh out-pfad lines subtyp merkmale) + ;; Vor dem Export: IDs aller Bloecke sicherstellen und Duplikate korrigieren + (princ "\n[OMNI_EXPORT] Pruefe und vergebe IDs...") + (ssg-id-check-all) ;; Vor dem Export HOEHE/DREHUNG aller Omniflo-Elemente aktualisieren (princ "\n[OMNI_EXPORT] Aktualisiere Hoehe/Drehung...") (omni:update-all-attribs) @@ -403,8 +391,12 @@ (setq cnt-boegen (1+ cnt-boegen)) (setq merkmale (csv:omni-bogen-merkmale ename rotation)) (setq lines (cons - (csv:omni-csv-line elem-nr "Omniflo Kurve" - (strcat "OFBogen :" (itoa cnt-boegen)) merkmale) + (strcat (itoa elem-nr) + ";\"Omniflo Kurve\"" + ";\"" (or (csv:get-attrib ename "ID") "0000") "\"" + ";\"" (strcat "OFBogen :" (itoa cnt-boegen)) "\"" + ";1" + ";" merkmale) lines)) ) @@ -421,8 +413,12 @@ ) (setq merkmale (csv:omni-weiche-merkmale ename rotation)) (setq lines (cons - (csv:omni-csv-line elem-nr "Omniflo Weiche" - (strcat "OFWeiche :" (itoa cnt-weichen)) merkmale) + (strcat (itoa elem-nr) + ";\"Omniflo Weiche\"" + ";\"" (or (csv:get-attrib ename "ID") "0000") "\"" + ";\"" (strcat "OFWeiche :" (itoa cnt-weichen)) "\"" + ";1" + ";" merkmale) lines)) ) @@ -437,8 +433,12 @@ ) (setq merkmale (csv:omni-gerade-merkmale ename rotation)) (setq lines (cons - (csv:omni-csv-line elem-nr "Omniflo Gerade" - (strcat "OFGerade :" (itoa cnt-geraden)) merkmale) + (strcat (itoa elem-nr) + ";\"Omniflo Gerade\"" + ";\"" (or (csv:get-attrib ename "ID") "0000") "\"" + ";\"" (strcat "OFGerade :" (itoa cnt-geraden)) "\"" + ";1" + ";" merkmale) lines)) ) ) diff --git a/lib/export_csv.py b/lib/export_csv.py index dd74165..76e5a61 100644 --- a/lib/export_csv.py +++ b/lib/export_csv.py @@ -13,7 +13,6 @@ CSV-Format: import json import sys import os -import uuid # --------------------------------------------------------------------------- @@ -35,10 +34,6 @@ def build_lookup(boegen, weichen): return lookup -def generate_shape_id(): - return "shape_" + str(uuid.uuid4()) - - # --------------------------------------------------------------------------- # Merkmale-Builder # --------------------------------------------------------------------------- @@ -151,7 +146,7 @@ def process_blocks(blocks, lookup): if bname in lookup: typ, eintrag = lookup[bname] elem_nr += 1 - shape_id = generate_shape_id() + shape_id = block.get("attribs", {}).get("ID", "0000") if typ == "bogen": bogen_count += 1 @@ -182,7 +177,7 @@ def process_blocks(blocks, lookup): items.append({ "nr": elem_nr, "teileart": "Omniflo Gerade", - "teileid": generate_shape_id(), + "teileid": block.get("attribs", {}).get("ID", "0000"), "bezeichnung": f"OFGerade :{gerade_count}", "merkmale": build_gerade_merkmale(block), }) @@ -195,7 +190,7 @@ def process_blocks(blocks, lookup): items.append({ "nr": elem_nr, "teileart": "ILS 2.0 Kreisel", - "teileid": generate_shape_id(), + "teileid": block.get("attribs", {}).get("ID", "0000"), "bezeichnung": f"Kreisel :{kreisel_count}", "merkmale": build_kreisel_merkmale(block), }) diff --git a/lib/export_sivas.py b/lib/export_sivas.py index 2da86d9..6c78a6b 100644 --- a/lib/export_sivas.py +++ b/lib/export_sivas.py @@ -15,7 +15,6 @@ Argumente: import json import sys import os -import uuid def load_json(path): @@ -35,10 +34,6 @@ def build_lookup(boegen, weichen): return lookup -def generate_shape_id(): - return "shape_" + str(uuid.uuid4()) - - def classify_weiche(eintrag): """Bestimmt den Weichen-Subtyp fuer die Omniflo Sum Zaehlung.""" wt = eintrag.get("WeichenTyp", "") @@ -213,7 +208,7 @@ def process_blocks(blocks, lookup): if bname in lookup: typ, eintrag = lookup[bname] elem_nr += 1 - shape_id = generate_shape_id() + shape_id = block.get("attribs", {}).get("ID", "0000") if typ == "bogen": bogen_count += 1 @@ -261,7 +256,7 @@ def process_blocks(blocks, lookup): items.append({ "nr": elem_nr, "teileart": "Omniflo Gerade", - "teileid": generate_shape_id(), + "teileid": block.get("attribs", {}).get("ID", "0000"), "bezeichnung": f"OFGerade :{gerade_count}", "anzahl": 1, "merkmale": build_gerade_merkmale(block) @@ -276,7 +271,7 @@ def process_blocks(blocks, lookup): items.append({ "nr": elem_nr, "teileart": "ILS 2.0 Kreisel", - "teileid": generate_shape_id(), + "teileid": block.get("attribs", {}).get("ID", "0000"), "bezeichnung": f"Kreisel :{kreisel_count}", "anzahl": 1, "merkmale": build_kreisel_merkmale(block)