From 9fe08411df259590422667dce649473c01d7b3b5 Mon Sep 17 00:00:00 2001 From: Michael Stangl Date: Thu, 11 Jun 2026 12:08:40 +0200 Subject: [PATCH] =?UTF-8?q?Update=20der=20Attribute=20H=C3=B6he=20und=20Dr?= =?UTF-8?q?ehung=20vor=20Aufruf=20der=20Exports=20durchgef=C3=BChrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Lisp/export.lsp | 31 +++++++++++++++++++++++++++++++ Lisp/ssg_load.lsp | 1 + lib/export_csv.py | 30 ++++++++++++++++++++++-------- lib/export_sivas.py | 30 ++++++++++++++++++++++-------- menu/SSG_LIB.mnu | 6 +++--- 5 files changed, 79 insertions(+), 19 deletions(-) diff --git a/Lisp/export.lsp b/Lisp/export.lsp index 9ae7511..d7df26d 100644 --- a/Lisp/export.lsp +++ b/Lisp/export.lsp @@ -108,6 +108,31 @@ ) +;; --- HOEHE/DREHUNG aller Omniflo-Elemente still aktualisieren --- +;; Wird automatisch vor jedem Export aufgerufen. +(defun omni:update-all-attribs ( / ss i ename ed bname teileart) + (setq ss (ssget "X" (list (cons 0 "INSERT")))) + (if ss + (progn + (setq i 0) + (while (setq ename (ssname ss i)) + (setq ed (entget ename)) + (setq bname (cdr (assoc 2 ed))) + (setq teileart (csv:get-attrib ename "TEILEART")) + (if (or teileart + (wcmatch (strcase bname) "AP110*,AP_110*")) + (progn + (omni:set-hoehe-attrib ename) + (omni:set-drehung-attrib ename) + ) + ) + (setq i (1+ i)) + ) + ) + ) +) + + ;; --- Gemeinsame Export-Funktion --- ;; Sammelt relevante Bloecke, schreibt JSON, ruft Python auf. ;; label = Anzeigename (z.B. "EXPORTCSV") @@ -115,6 +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 HOEHE/DREHUNG aller Omniflo-Elemente aktualisieren + (princ (strcat "\n[" label "] Aktualisiere Hoehe/Drehung...")) + (omni:update-all-attribs) (princ (strcat "\n[" label "] Sammle relevante Bloecke...")) (setq ss (csv:collect-export-blocks)) @@ -338,6 +366,9 @@ len-ap110 len-ap60 laenge-str fh out-pfad lines subtyp merkmale) + ;; Vor dem Export HOEHE/DREHUNG aller Omniflo-Elemente aktualisieren + (princ "\n[OMNI_EXPORT] Aktualisiere Hoehe/Drehung...") + (omni:update-all-attribs) (princ "\n[OMNI_EXPORT] Sammle Omniflo-Elemente...") (setq ss-all (ssget "X" (list (cons 0 "INSERT")))) (if (null ss-all) diff --git a/Lisp/ssg_load.lsp b/Lisp/ssg_load.lsp index 47726d7..ec45a59 100644 --- a/Lisp/ssg_load.lsp +++ b/Lisp/ssg_load.lsp @@ -26,6 +26,7 @@ ;; KreiselInsert.lsp entfernt - ersetzt durch Python/PyRx (lib/elemente/kreisel.py, eckrad.py) (load (strcat base-path "VarioFoerderer.lsp") "VarioFoerderer.lsp nicht gefunden") (load (strcat base-path "Gefaellestrecke.lsp") "Gefaellestrecke.lsp nicht gefunden") + (load (strcat base-path "export.lsp") "export.lsp nicht gefunden") (load (strcat base-path "tests.lsp") "tests.lsp nicht gefunden") ;; OmniModulInsert.lsp entfernt - ersetzt durch Python/PyRx (lib/elemente/omniflo*.py) (load (strcat base-path "SSG_LIB_Commands.lsp") "SSG_LIB_Commands.lsp nicht gefunden") diff --git a/lib/export_csv.py b/lib/export_csv.py index 2e95926..c34e765 100644 --- a/lib/export_csv.py +++ b/lib/export_csv.py @@ -43,13 +43,30 @@ def generate_shape_id(): # Merkmale-Builder # --------------------------------------------------------------------------- +def get_hoehe(block): + """Liest HOEHE aus Block-Attributen. Fallback: Z-Koordinate.""" + attribs = block.get("attribs", {}) + return attribs.get("HOEHE") or str(int(block.get("z", 0) or 0)) or "2000" + + +def get_drehung(block): + """Liest DREHUNG aus Block-Attributen. Fallback: CAD-Rotation.""" + attribs = block.get("attribs", {}) + drehung_raw = attribs.get("DREHUNG") + if drehung_raw is not None: + try: + return float(drehung_raw) + except (ValueError, TypeError): + pass + return block.get("rotation", 0.0) + + def build_bogen_merkmale(block, eintrag): return { - "Länge in Meter": "0", "Kurvenwinkel": eintrag.get("KurvenWinkel", 0), "Radius": eintrag.get("Radius", 0), - "Höhe": "2000", - "Drehung": block.get("rotation", 0.0), + "Höhe": get_hoehe(block), + "Drehung": get_drehung(block), "SivasNummer": str(eintrag.get("Sivasnr", "")) } @@ -57,14 +74,11 @@ def build_bogen_merkmale(block, eintrag): def build_weiche_merkmale(block, eintrag): wt = eintrag.get("WeichenTyp", "Einzelweiche") return { - "Länge in Meter links": 0, - "Länge in Meter rechts": 0, - "Länge in Meter gerade": 0, "Weichentyp": wt, "Richtung": str(eintrag.get("KurvenRichtung", "")), "Weichenwinkel": eintrag.get("KurvenWinkel", 0), - "Höhe": "2000", - "Drehung": block.get("rotation", 0.0), + "Höhe": get_hoehe(block), + "Drehung": get_drehung(block), "Antrieb Kurve": eintrag.get("SivasnrTEF") is not None, "SivasNummer": str(eintrag.get("Sivasnr", "")) } diff --git a/lib/export_sivas.py b/lib/export_sivas.py index 8d5aa7c..2da86d9 100644 --- a/lib/export_sivas.py +++ b/lib/export_sivas.py @@ -60,14 +60,31 @@ def classify_weiche(eintrag): return "einzelweiche" +def get_hoehe(block): + """Liest HOEHE aus Block-Attributen. Fallback: Z-Koordinate.""" + attribs = block.get("attribs", {}) + return attribs.get("HOEHE") or str(int(block.get("z", 0) or 0)) or "2000" + + +def get_drehung(block): + """Liest DREHUNG aus Block-Attributen. Fallback: CAD-Rotation.""" + attribs = block.get("attribs", {}) + drehung_raw = attribs.get("DREHUNG") + if drehung_raw is not None: + try: + return float(drehung_raw) + except (ValueError, TypeError): + pass + return block.get("rotation", 0.0) + + def build_bogen_merkmale(block, eintrag): """Merkmale-JSON fuer einen Omniflo Bogen.""" return { - "Länge in Meter": "0", "Kurvenwinkel": eintrag.get("KurvenWinkel", 0), "Radius": eintrag.get("Radius", 0), - "Höhe": "2000", - "Drehung": block.get("rotation", 0.0), + "Höhe": get_hoehe(block), + "Drehung": get_drehung(block), "SivasNummer": str(eintrag.get("Sivasnr", "")) } @@ -76,14 +93,11 @@ def build_weiche_merkmale(block, eintrag): """Merkmale-JSON fuer eine Omniflo Weiche.""" wt = eintrag.get("WeichenTyp", "Einzelweiche") return { - "Länge in Meter links": 0, - "Länge in Meter rechts": 0, - "Länge in Meter gerade": 0, "Weichentyp": wt, "Richtung": str(eintrag.get("KurvenRichtung", "")), "Weichenwinkel": eintrag.get("KurvenWinkel", 0), - "Höhe": "2000", - "Drehung": block.get("rotation", 0.0), + "Höhe": get_hoehe(block), + "Drehung": get_drehung(block), "Antrieb Kurve": eintrag.get("SivasnrTEF") is not None, "SivasNummer": str(eintrag.get("Sivasnr", "")) } diff --git a/menu/SSG_LIB.mnu b/menu/SSG_LIB.mnu index 11df845..399a72d 100644 --- a/menu/SSG_LIB.mnu +++ b/menu/SSG_LIB.mnu @@ -63,9 +63,9 @@ [Doppel Parallel 200/750 M]^C^COMNI_WP_Doppel [<-Dreiwege Parallel 200/750 M]^C^COMNI_WP_Dreiwege [->Weichenkoerper] -[Weichenkoerper Einfach 22.5 links M]^C^COMNI_WK_Einfach -[Weichenkoerper Doppel 22.5 M]^C^COMNI_WK_Doppel -[<-Weichenkoerper Dreiwege 22.5 M]^C^COMNI_WK_Dreiwege +[Einfach 22.5 links M]^C^COMNI_WK_Einfach +[Doppel 22.5 M]^C^COMNI_WK_Doppel +[<-Dreiwege 22.5 M]^C^COMNI_WK_Dreiwege [->Weichenkombinationen] [Delta 1400/700 M]^C^COMNI_WKomb_Delta [<-Star 1400/1400 M]^C^COMNI_WKomb_Star