Omniflo Weichen Interface gebaut

This commit is contained in:
2026-05-08 14:36:42 +02:00
parent 1deaa2e361
commit a2cdc4e87b
2 changed files with 328 additions and 28 deletions
+299 -28
View File
@@ -569,78 +569,349 @@
(princ) (princ)
) )
;; ============================================================
;; OMNIFLO WEICHEN-DIALOG
;; Generischer Dialog fuer Weichen-Auswahl nach Winkel/Typ
;; mit Filter fuer Schaltungstyp und Richtung
;; ============================================================
;; --- Aktuelle Filterwerte aus Radio-Buttons lesen ---
(defun omni:weichen-get-filter ( / sch ri)
(setq sch "alle")
(if (= (get_tile "sch_m") "1") (setq sch "M"))
(if (= (get_tile "sch_p") "1") (setq sch "P"))
(setq ri "alle")
(if (= (get_tile "ri_links") "1") (setq ri "1"))
(if (= (get_tile "ri_rechts") "1") (setq ri "2"))
(list sch ri)
)
;; --- Gefilterte Weichen-Liste aufbauen ---
;; basis-liste = alle Weichen fuer den gewaehlten Winkel/Typ
;; sch-filter = "M", "P" oder "alle"
;; ri-filter = "1", "2" oder "alle"
(defun omni:weichen-filter-liste (basis-liste sch-filter ri-filter / eintrag sch kr ergebnis)
(setq ergebnis nil)
(foreach eintrag basis-liste
(setq sch (cdr (assoc "Schaltungstyp" eintrag)))
(setq kr (cdr (assoc "KurvenRichtung" eintrag)))
(if (and
(or (= sch-filter "alle") (= sch sch-filter))
(or (= ri-filter "alle")
(= (omni:sivasid-to-str kr) ri-filter))
)
(setq ergebnis (cons eintrag ergebnis))
)
)
(reverse ergebnis)
)
;; --- Dropdown mit gefilterter Liste neu befuellen ---
(defun omni:weichen-dlg-refresh ( / filter sch-f ri-f gefiltert profil-liste)
(setq filter (omni:weichen-get-filter))
(setq sch-f (car filter))
(setq ri-f (cadr filter))
(setq gefiltert (omni:weichen-filter-liste *OMNI-DLG-WEICHEN-BASIS* sch-f ri-f))
(setq *OMNI-DLG-WEICHEN* gefiltert)
;; Dropdown neu befuellen
(setq profil-liste
(mapcar '(lambda (e) (cdr (assoc "ProfilTyp" e))) gefiltert))
(start_list "profiltyp")
(mapcar 'add_list profil-liste)
(end_list)
;; Ersten Eintrag anzeigen (falls vorhanden)
(if gefiltert
(progn
(set_tile "profiltyp" "0")
(omni:weichen-dlg-update "0")
)
(progn
(set_tile "val_sivasnr" "---")
(set_tile "val_winkel" "---")
(set_tile "val_breite" "---")
(set_tile "val_laenge" "---")
)
)
)
;; --- Detail-Felder im Weichen-Dialog aktualisieren ---
(defun omni:weichen-dlg-update (idx-str / idx eintrag wkl)
(setq idx (atoi idx-str))
(setq eintrag (nth idx *OMNI-DLG-WEICHEN*))
(if eintrag
(progn
(set_tile "val_sivasnr"
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")))
(setq wkl (omni:val eintrag "KurvenWinkel"))
(set_tile "val_winkel"
(if (= (type wkl) 'INT) (strcat (itoa wkl) " Grad")
(strcat (rtos wkl 2 1) " Grad")
)
)
(set_tile "val_breite"
(itoa (fix (omni:val eintrag "Breite"))))
(set_tile "val_laenge"
(itoa (fix (omni:val eintrag "Länge"))))
)
)
)
;; --- Weichen-Auswahl-Dialog oeffnen ---
;; winkel = KurvenWinkel (90, 45, 0, 22.5)
;; weichentyp = "Einzelweiche", "Doppelweiche", "Dreiwegeweiche" oder nil fuer alle
;; Rueckgabe: gewaehlter Weichen-Eintrag (alist) oder nil bei Abbruch
(defun omni:weichen-dialog (winkel weichentyp / dcl-pfad dat basis-liste
profil-liste ergebnis)
(if (null *OMNI-WEICHEN*) (omni:load-data))
;; Weichen nach Winkel filtern (nil = alle Winkel)
(if winkel
(setq basis-liste (omni:filter *OMNI-WEICHEN* "KurvenWinkel" winkel))
(setq basis-liste *OMNI-WEICHEN*)
)
;; Optional nach WeichenTyp filtern
(if weichentyp
(setq basis-liste
(vl-remove-if-not
'(lambda (e) (= (cdr (assoc "WeichenTyp" e)) weichentyp))
basis-liste))
)
(if (null basis-liste)
(progn
(alert (strcat "Keine Weichen fuer "
(cond
((null winkel) "alle Winkel")
((= (type winkel) 'INT) (strcat (itoa winkel) " Grad"))
(T (strcat (rtos winkel 2 1) " Grad"))
)
(if weichentyp (strcat " / " weichentyp) "")
" gefunden."))
nil
)
(progn
;; Basis-Liste und gefilterte Liste in globalen Variablen speichern
(setq *OMNI-DLG-WEICHEN-BASIS* basis-liste)
(setq *OMNI-DLG-WEICHEN* basis-liste)
;; ProfilTyp-Liste fuer Dropdown aufbauen
(setq profil-liste
(mapcar '(lambda (e) (cdr (assoc "ProfilTyp" e))) basis-liste))
;; DCL laden
(setq dcl-pfad (strcat (getenv "DXFM_DCL") "/omniflo_weichen.dcl"))
(setq dat (load_dialog dcl-pfad))
(if (not (new_dialog "omniflo_weichen" dat))
(progn (alert "Weichen-Dialog konnte nicht geladen werden.") nil)
(progn
;; Dropdown befuellen
(start_list "profiltyp")
(mapcar 'add_list profil-liste)
(end_list)
(set_tile "profiltyp" "0")
;; Startwerte anzeigen
(omni:weichen-dlg-update "0")
;; Callback bei Dropdown-Aenderung
(action_tile "profiltyp" "(omni:weichen-dlg-update $value)")
;; Callbacks fuer Filter-Radio-Buttons (alle loesen Refresh aus)
(action_tile "sch_alle" "(omni:weichen-dlg-refresh)")
(action_tile "sch_m" "(omni:weichen-dlg-refresh)")
(action_tile "sch_p" "(omni:weichen-dlg-refresh)")
(action_tile "ri_alle" "(omni:weichen-dlg-refresh)")
(action_tile "ri_links" "(omni:weichen-dlg-refresh)")
(action_tile "ri_rechts" "(omni:weichen-dlg-refresh)")
;; OK/Abbrechen
(action_tile "accept"
"(setq ergebnis (atoi (get_tile \"profiltyp\"))) (done_dialog 1)")
(action_tile "cancel" "(done_dialog 0)")
(start_dialog)
(unload_dialog dat)
;; Gewaehlten Eintrag zurueckgeben
(if ergebnis
(nth ergebnis *OMNI-DLG-WEICHEN*)
nil
)
)
)
)
)
)
;; ============================================================
;; OMNIFLO WEICHEN-BEFEHLE
;; ============================================================
;; --- Omniflo / Weiche 90 Grad --- ;; --- Omniflo / Weiche 90 Grad ---
(defun c:OMNI_W90_Einfach () (defun c:OMNI_W90_Einfach ( / eintrag)
(princ "\n[DUMMY] Einfach 90 700/700 links M (834372027)") (setq eintrag (omni:weichen-dialog 90 "Einzelweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
(defun c:OMNI_W90_Doppel () (defun c:OMNI_W90_Doppel ( / eintrag)
(princ "\n[DUMMY] Doppel 90 700/700 M (834372109)") (setq eintrag (omni:weichen-dialog 90 "Doppelweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
(defun c:OMNI_W90_Dreiwege () (defun c:OMNI_W90_Dreiwege ( / eintrag)
(princ "\n[DUMMY] Dreiwege 90 700/700 M (834372209)") (setq eintrag (omni:weichen-dialog 90 "Dreiwegeweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
;; --- Omniflo / Weiche 45 Grad --- ;; --- Omniflo / Weiche 45 Grad ---
(defun c:OMNI_W45_Einfach () (defun c:OMNI_W45_Einfach ( / eintrag)
(princ "\n[DUMMY] Einfach 45 350/700 links M (834372001)") (setq eintrag (omni:weichen-dialog 45 "Einzelweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
(defun c:OMNI_W45_Doppel () (defun c:OMNI_W45_Doppel ( / eintrag)
(princ "\n[DUMMY] Doppel 45 350/700 M (834372100)") (setq eintrag (omni:weichen-dialog 45 "Doppelweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
(defun c:OMNI_W45_Dreiwege () (defun c:OMNI_W45_Dreiwege ( / eintrag)
(princ "\n[DUMMY] Dreiwege 45 350/700 M (834372200)") (setq eintrag (omni:weichen-dialog 45 "Dreiwegeweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
;; --- Omniflo / Weichen Parallel --- ;; --- Omniflo / Weichen Parallel ---
(defun c:OMNI_WP_Einfach () (defun c:OMNI_WP_Einfach ( / eintrag)
(princ "\n[DUMMY] Einfach Parallel 200/750 links M (834372047)") (setq eintrag (omni:weichen-dialog 0 "Einzelweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
(defun c:OMNI_WP_Doppel () (defun c:OMNI_WP_Doppel ( / eintrag)
(princ "\n[DUMMY] Doppel Parallel 200/750 M (834372115)") (setq eintrag (omni:weichen-dialog 0 "Doppelweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
(defun c:OMNI_WP_Dreiwege () (defun c:OMNI_WP_Dreiwege ( / eintrag)
(princ "\n[DUMMY] Dreiwege Parallel 200/750 M (834372215)") (setq eintrag (omni:weichen-dialog 0 "Dreiwegeweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
;; --- Omniflo / Weichenkoerper --- ;; --- Omniflo / Weichenkoerper ---
(defun c:OMNI_WK_Einfach () (defun c:OMNI_WK_Einfach ( / eintrag)
(princ "\n[DUMMY] Weichenkoerper Einfach 22.5 links M (834342011)") (setq eintrag (omni:weichen-dialog 22.5 "Einzelweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
(defun c:OMNI_WK_Doppel () (defun c:OMNI_WK_Doppel ( / eintrag)
(princ "\n[DUMMY] Weichenkoerper Doppel 22.5 M (834342100)") (setq eintrag (omni:weichen-dialog 22.5 "Doppelweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
(defun c:OMNI_WK_Dreiwege () (defun c:OMNI_WK_Dreiwege ( / eintrag)
(princ "\n[DUMMY] Weichenkoerper Dreiwege 22.5 M (834342200)") (setq eintrag (omni:weichen-dialog 22.5 "Dreiwegeweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
;; --- Omniflo / Weichenkombinationen --- ;; --- Omniflo / Weichenkombinationen ---
(defun c:OMNI_WKomb_Delta () (defun c:OMNI_WKomb_Delta ( / eintrag)
(princ "\n[DUMMY] Delta 1400/700 M (834372400)") (setq eintrag (omni:weichen-dialog nil "Deltaweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
(defun c:OMNI_WKomb_Star () (defun c:OMNI_WKomb_Star ( / eintrag)
(princ "\n[DUMMY] Star 1400/1400 M (834372420)") (setq eintrag (omni:weichen-dialog nil "Sternweiche"))
(if eintrag
(princ (strcat "\n[WEICHE] Gewaehlt: "
(omni:val eintrag "ProfilTyp") " (SivasNr: "
(omni:sivasid-to-str (omni:val eintrag "Sivasnr")) ")"))
(princ "\n[WEICHE] Abgebrochen.")
)
(princ) (princ)
) )
+29
View File
@@ -0,0 +1,29 @@
"""testpycall.py - Testskript fuer LISP-Python-Aufruf."""
import os
import sys
from datetime import datetime
def main():
if len(sys.argv) > 1:
log_dir = sys.argv[1]
else:
log_dir = os.getenv("DXFM_LOG", ".")
os.makedirs(log_dir, exist_ok=True)
log_file = os.path.join(log_dir, "testpycall.log")
return_file = os.path.join(log_dir, "testpycall_return.txt")
timestamp = datetime.now().strftime("%y%m%d-%H:%M:%S")
message = f"{timestamp} - been called from BricsCAD LISP via CALLPYTHON\n"
with open(log_file, "a", encoding="utf-8") as f:
f.write(message)
with open(return_file, "w", encoding="utf-8") as f:
f.write(timestamp)
if __name__ == "__main__":
main()