1134 lines
47 KiB
Common Lisp
1134 lines
47 KiB
Common Lisp
;; ============================================================
|
||
;; VF_STANDARD - Standard VarioFoerderer (Typ: "standard")
|
||
;; Version: 26.0
|
||
;; Abhaengigkeit: vf_core.lsp muss zuerst geladen sein
|
||
;; Geometrie: AS/ES 90 Grad, horizontal versetzt
|
||
;; 11-Schritt-Einfuegung
|
||
;; ============================================================
|
||
|
||
;; Sicherstellen, dass vf_core.lsp geladen ist
|
||
(if (not (car (atoms-family 1 '("VF-TYP-REGISTRIEREN"))))
|
||
(progn
|
||
(setq *vf-std-core-pfad*
|
||
(cond
|
||
((getenv "DXFM_LISP")
|
||
(vl-string-translate "\\" "/" (getenv "DXFM_LISP")))
|
||
((and (boundp '*ssg-lisp-pfad*) *ssg-lisp-pfad*)
|
||
*ssg-lisp-pfad*)
|
||
(t nil)
|
||
)
|
||
)
|
||
(if *vf-std-core-pfad*
|
||
(load (strcat *vf-std-core-pfad* "/vf_core.lsp"))
|
||
(progn
|
||
(princ (ssg-text "vfs-warn-lisppfad"))
|
||
(exit)
|
||
)
|
||
)
|
||
)
|
||
)
|
||
|
||
;; ============================================================
|
||
;; TEIL 1: STANDARD-SPEZIFISCHE GLOBALE VARIABLEN
|
||
;; ============================================================
|
||
(setq aus-dx nil aus-dy nil aus-dz nil)
|
||
(setq ein-dx nil ein-dy nil ein-dz nil)
|
||
(setq separator-laenge nil umlenk-laenge nil motorstation-laenge nil)
|
||
(setq staustrecke-basis 1000)
|
||
(setq FESTE_HORIZONTAL 1600)
|
||
|
||
(setq bogen-auf '())
|
||
(setq bogen-ab '())
|
||
|
||
(setq *lib-initialized* nil)
|
||
(setq *bogen-cache-loaded* nil)
|
||
(setq *modul-cache* nil)
|
||
|
||
;; ============================================================
|
||
;; TEIL 2: BLOCK-DATEI-PRUEFUNG
|
||
;; ============================================================
|
||
;; Prueft ob alle benoetigten Block-Dateien vorhanden sind.
|
||
;; Gibt t zurueck wenn OK (oder Library-DXF vorhanden), nil wenn Einzeldateien fehlen.
|
||
(defun vf-check-required-blocks ( / lib-datei bogen-winkel required-blocks missing bname datei)
|
||
(setq lib-datei
|
||
(strcat (vl-string-translate "\\" "/" (getenv "DXFM_DATA"))
|
||
"/block_libraries/ils_library.dxf"))
|
||
(if (findfile lib-datei)
|
||
t ;; Library-Datei vorhanden: alle Bloecke darin verfuegbar
|
||
(progn
|
||
(setq bogen-winkel (ssg-cfg-or "vario" "bogen_winkel"
|
||
'(3 6 9 12 15 18 21 27 33 39 45 51)))
|
||
(setq required-blocks
|
||
(append
|
||
(list "AS_Element_90_links" "AS_Element_90_rechts"
|
||
"ES_Element_90_links" "ES_Element_90_rechts"
|
||
"Staustrecke_SP_1000_mm" "Staustrecke_Separator_SP_300_mm"
|
||
"Vario_Umlenkstation_500mm" "Vario_Motorstation_500mm")
|
||
(mapcar (function (lambda (w) (strcat "Vario_Bogen_auf_" (itoa w)))) bogen-winkel)
|
||
(mapcar (function (lambda (w) (strcat "Vario_Bogen_ab_" (itoa w)))) bogen-winkel)
|
||
)
|
||
)
|
||
(setq missing '())
|
||
(foreach bname required-blocks
|
||
(setq datei (strcat block-pfad bname ".dwg"))
|
||
(if (not (findfile datei))
|
||
(setq missing (cons datei missing))
|
||
)
|
||
)
|
||
(if missing
|
||
(progn
|
||
(princ (ssg-textf "vfs-block-fehler-pfad" (list block-pfad)))
|
||
(princ (ssg-text "vfs-block-fehlende-header"))
|
||
(foreach f (reverse missing)
|
||
(princ (ssg-textf "vfs-block-fehlende-item" (list f)))
|
||
)
|
||
nil
|
||
)
|
||
t
|
||
)
|
||
)
|
||
)
|
||
)
|
||
|
||
;; ============================================================
|
||
;; TEIL 3: BIBLIOTHEK INITIALISIEREN
|
||
;; ============================================================
|
||
(defun init-bibliothek ( / temp-obj bogen-winkel ks-data ks-ein-pos ks-aus-pos
|
||
dx dy dz bogen-name)
|
||
;; "bereits initialisiert" nur, wenn das Flag gesetzt UND die Bogen-Tabelle
|
||
;; tatsaechlich befuellt ist. Sonst (Stuck-State: Flag gesetzt, aber bogen-auf
|
||
;; leer - z.B. nach einer fehlgeschlagenen Extraktion) neu initialisieren.
|
||
(if (and *lib-initialized* bogen-auf bogen-ab
|
||
(tblsearch "BLOCK" "AS_Element_90_links"))
|
||
(progn
|
||
(princ (ssg-text "vfs-lib-bereits-init"))
|
||
t
|
||
)
|
||
(if (not (vf-check-required-blocks))
|
||
nil
|
||
(progn
|
||
(setq *lib-initialized* nil)
|
||
(setq *ks-cache* nil)
|
||
(princ (ssg-text "vfs-lib-init-start"))
|
||
|
||
;; AS_90 Masse extrahieren
|
||
(princ (ssg-text "vfs-extrahiere-aus"))
|
||
(ensure-block-loaded "AS_Element_90_links")
|
||
(ensure-block-loaded "AS_Element_90_rechts")
|
||
(if (tblsearch "BLOCK" "AS_Element_90_links")
|
||
(progn
|
||
(setq temp-obj (vla-InsertBlock modelspace
|
||
(vlax-3D-point '(0 0 0))
|
||
"AS_Element_90_links" 1.0 1.0 1.0 0))
|
||
(setq ks-data (extract-ks-from-block temp-obj))
|
||
(vla-Delete temp-obj)
|
||
(setq ks-ein-pos nil ks-aus-pos nil)
|
||
(foreach item ks-data
|
||
(if (= (car item) "KS_EIN") (setq ks-ein-pos (cadr item)))
|
||
(if (= (car item) "KS_AUS") (setq ks-aus-pos (cadr item)))
|
||
)
|
||
(if (and ks-ein-pos ks-aus-pos)
|
||
(progn
|
||
(setq aus-dx (- (caar ks-aus-pos) (caar ks-ein-pos)))
|
||
(setq aus-dy (- (cadr (car ks-aus-pos)) (cadr (car ks-ein-pos))))
|
||
(setq aus-dz (- (caddr (car ks-aus-pos)) (caddr (car ks-ein-pos))))
|
||
(princ (ssg-textf "vfs-as90-mass" (list (rtos aus-dx 2 0) (rtos aus-dz 2 0))))
|
||
)
|
||
(princ (ssg-text "vfs-fehler-ks-as90"))
|
||
)
|
||
)
|
||
(princ (ssg-text "vfs-fehler-block-as90"))
|
||
)
|
||
|
||
;; ES_90 Masse extrahieren
|
||
(princ (ssg-text "vfs-extrahiere-ein"))
|
||
(ensure-block-loaded "ES_Element_90_links")
|
||
(ensure-block-loaded "ES_Element_90_rechts")
|
||
(if (tblsearch "BLOCK" "ES_Element_90_links")
|
||
(progn
|
||
(setq temp-obj (vla-InsertBlock modelspace
|
||
(vlax-3D-point '(0 0 0))
|
||
"ES_Element_90_links" 1.0 1.0 1.0 0))
|
||
(setq ks-data (extract-ks-from-block temp-obj))
|
||
(vla-Delete temp-obj)
|
||
(setq ks-ein-pos nil ks-aus-pos nil)
|
||
(foreach item ks-data
|
||
(if (= (car item) "KS_EIN") (setq ks-ein-pos (cadr item)))
|
||
(if (= (car item) "KS_AUS") (setq ks-aus-pos (cadr item)))
|
||
)
|
||
(if (and ks-ein-pos ks-aus-pos)
|
||
(progn
|
||
(setq ein-dx (- (caar ks-aus-pos) (caar ks-ein-pos)))
|
||
(setq ein-dy (- (cadr (car ks-aus-pos)) (cadr (car ks-ein-pos))))
|
||
(setq ein-dz (- (caddr (car ks-aus-pos)) (caddr (car ks-ein-pos))))
|
||
(princ (ssg-textf "vfs-es90-mass" (list (rtos ein-dx 2 0) (rtos ein-dz 2 0))))
|
||
)
|
||
(princ (ssg-text "vfs-fehler-ks-es90"))
|
||
)
|
||
)
|
||
(princ (ssg-text "vfs-fehler-block-es90"))
|
||
)
|
||
|
||
;; Bogen-Masse extrahieren
|
||
(princ (ssg-text "vfs-extrahiere-bogen"))
|
||
(setq bogen-auf '())
|
||
(setq bogen-ab '())
|
||
(setq bogen-winkel (ssg-cfg-or "vario" "bogen_winkel"
|
||
'(3 6 9 12 15 18 21 27 33 39 45 51)))
|
||
(foreach w bogen-winkel
|
||
;; Aufwaertsbogen
|
||
(setq bogen-name (strcat "Vario_Bogen_auf_" (itoa w)))
|
||
(ensure-block-loaded bogen-name)
|
||
(if (tblsearch "BLOCK" bogen-name)
|
||
(progn
|
||
(setq temp-obj (vla-InsertBlock modelspace
|
||
(vlax-3D-point '(0 0 0)) bogen-name 1.0 1.0 1.0 0))
|
||
(setq ks-data (extract-ks-from-block temp-obj))
|
||
(vla-Delete temp-obj)
|
||
(setq ks-ein-pos nil ks-aus-pos nil)
|
||
(foreach item ks-data
|
||
(if (= (car item) "KS_EIN") (setq ks-ein-pos (cadr item)))
|
||
(if (= (car item) "KS_AUS") (setq ks-aus-pos (cadr item)))
|
||
)
|
||
(if (and ks-ein-pos ks-aus-pos)
|
||
(progn
|
||
(setq dx (- (caar ks-aus-pos) (caar ks-ein-pos)))
|
||
(setq dy (- (cadr (car ks-aus-pos)) (cadr (car ks-ein-pos))))
|
||
(setq dz (- (caddr (car ks-aus-pos)) (caddr (car ks-ein-pos))))
|
||
(setq bogen-auf (cons (list w dx dy dz) bogen-auf))
|
||
(princ (ssg-textf "vfs-bogen-auf-ok" (list (itoa w) (rtos dx 2 0) (rtos dz 2 0))))
|
||
)
|
||
(princ (ssg-textf "vfs-bogen-auf-ks-fehlt" (list (itoa w))))
|
||
)
|
||
)
|
||
(princ (ssg-textf "vfs-bogen-auf-block-fehlt" (list (itoa w))))
|
||
)
|
||
;; Abwaertsbogen
|
||
(setq bogen-name (strcat "Vario_Bogen_ab_" (itoa w)))
|
||
(ensure-block-loaded bogen-name)
|
||
(if (tblsearch "BLOCK" bogen-name)
|
||
(progn
|
||
(setq temp-obj (vla-InsertBlock modelspace
|
||
(vlax-3D-point '(0 0 0)) bogen-name 1.0 1.0 1.0 0))
|
||
(setq ks-data (extract-ks-from-block temp-obj))
|
||
(vla-Delete temp-obj)
|
||
(setq ks-ein-pos nil ks-aus-pos nil)
|
||
(foreach item ks-data
|
||
(if (= (car item) "KS_EIN") (setq ks-ein-pos (cadr item)))
|
||
(if (= (car item) "KS_AUS") (setq ks-aus-pos (cadr item)))
|
||
)
|
||
(if (and ks-ein-pos ks-aus-pos)
|
||
(progn
|
||
(setq dx (- (caar ks-aus-pos) (caar ks-ein-pos)))
|
||
(setq dy (- (cadr (car ks-aus-pos)) (cadr (car ks-ein-pos))))
|
||
(setq dz (- (caddr (car ks-aus-pos)) (caddr (car ks-ein-pos))))
|
||
(setq bogen-ab (cons (list w dx dy dz) bogen-ab))
|
||
(princ (ssg-textf "vfs-bogen-ab-ok" (list (itoa w) (rtos dx 2 0) (rtos dz 2 0))))
|
||
)
|
||
(princ (ssg-textf "vfs-bogen-ab-ks-fehlt" (list (itoa w))))
|
||
)
|
||
)
|
||
(princ (ssg-textf "vfs-bogen-ab-block-fehlt" (list (itoa w))))
|
||
)
|
||
)
|
||
(setq bogen-auf (reverse bogen-auf))
|
||
(setq bogen-ab (reverse bogen-ab))
|
||
(setq *lib-initialized* t)
|
||
(princ (ssg-text "vfs-lib-init-erfolg"))
|
||
t
|
||
) ;; end progn (Initialisierung)
|
||
) ;; end (if not vf-check-required-blocks)
|
||
) ;; end outer (if and *lib-initialized*)
|
||
)
|
||
|
||
;; ============================================================
|
||
;; TEIL 3: BOGEN-MASSE
|
||
;; ============================================================
|
||
(defun get-bogen-mass (tabelle winkel)
|
||
(setq result nil)
|
||
(foreach item tabelle
|
||
(if (= (car item) winkel) (setq result (cdr item)))
|
||
)
|
||
(if (null result)
|
||
(princ (ssg-textf "vfs-fehler-winkel-tabelle" (list (itoa winkel))))
|
||
)
|
||
result
|
||
)
|
||
|
||
;; ============================================================
|
||
;; TEIL 4: WINKELBERECHNUNG
|
||
;; ============================================================
|
||
;; feste-hz: horizontales Budget der festen Elemente (Umlenk+Motor+Separatoren).
|
||
;; nil => Standardwert FESTE_HORIZONTAL (1600, Standard-VF mit 2 Separatoren).
|
||
;; Der Linienzug uebergibt 1300 (nur 1 Separator am Einlauf, siehe vf_linienzug).
|
||
(defun berechne-alle-winkel (deltaL deltaH richtung feste-hz /
|
||
winkel-list ergebnis-liste A B cos3 sin3
|
||
bogen-x1 bogen-z1 bogen-x2 bogen-z2
|
||
abs-dz-AUS abs-dz-EIN L_GF L_VF cosα sinα
|
||
winkel-eff cosEff sinEff rad5 rad7
|
||
winkel mass1 mass2 gueltig
|
||
best-winkel best-L_GF best-L_VF)
|
||
|
||
(if (or (not *lib-initialized*) (null aus-dz) (null ein-dz))
|
||
(progn
|
||
(princ (ssg-text "vfs-fehler-lib-nicht-init"))
|
||
(exit)
|
||
)
|
||
)
|
||
(if (null feste-hz) (setq feste-hz FESTE_HORIZONTAL))
|
||
|
||
(setq abs-dz-AUS (abs aus-dz) abs-dz-EIN (abs ein-dz))
|
||
(setq winkel-list (ssg-cfg-or "vario" "bogen_winkel"
|
||
'(3 6 9 12 15 18 21 27 33 39 45 51)))
|
||
(setq ergebnis-liste '())
|
||
(setq cos3 (cos (* (ssg-cfg-or "vario" "gefaelle_winkel" 3) (/ pi 180.0)))
|
||
sin3 (sin (* (ssg-cfg-or "vario" "gefaelle_winkel" 3) (/ pi 180.0))))
|
||
|
||
(princ "\n\n=========================================")
|
||
(princ (ssg-text "vfs-berechnung-header"))
|
||
(princ "\n=========================================")
|
||
(princ (ssg-textf "vfs-berechnung-parameter"
|
||
(list (rtos deltaL 2 2) (rtos deltaH 2 2) richtung)))
|
||
|
||
(foreach winkel winkel-list
|
||
(if (= richtung "Auf")
|
||
(progn
|
||
(setq mass1 (get-bogen-mass bogen-auf winkel))
|
||
(setq mass2 (get-bogen-mass bogen-ab winkel))
|
||
)
|
||
(progn
|
||
(setq mass1 (get-bogen-mass bogen-ab winkel))
|
||
(setq mass2 (get-bogen-mass bogen-auf winkel))
|
||
)
|
||
)
|
||
(if (or (null mass1) (null mass2))
|
||
(setq ergebnis-liste (cons (list winkel nil nil nil) ergebnis-liste))
|
||
(progn
|
||
(setq rad5 (* 3.0 (/ pi 180.0)))
|
||
(setq rad7 (* (float (if (= richtung "Auf") (- 3 winkel) (+ winkel 3)))
|
||
(/ pi 180.0)))
|
||
(setq bogen-x1 (+ (* (car mass1) (cos rad5)) (* (caddr mass1) (sin rad5))))
|
||
(setq bogen-z1 (+ (* (- (car mass1)) (sin rad5)) (* (caddr mass1) (cos rad5))))
|
||
(setq bogen-x2 (+ (* (car mass2) (cos rad7)) (* (caddr mass2) (sin rad7))))
|
||
(setq bogen-z2 (+ (* (- (car mass2)) (sin rad7)) (* (caddr mass2) (cos rad7))))
|
||
(setq cosα (cos (* winkel (/ pi 180.0)))
|
||
sinα (sin (* winkel (/ pi 180.0))))
|
||
(setq A (- deltaL aus-dx ein-dx bogen-x1 bogen-x2
|
||
(* feste-hz cos3)))
|
||
(setq winkel-eff (if (= richtung "Auf") (- winkel 3) (+ winkel 3)))
|
||
(setq cosEff (cos (* winkel-eff (/ pi 180.0)))
|
||
sinEff (sin (* winkel-eff (/ pi 180.0))))
|
||
(if (= richtung "Auf")
|
||
(setq B (+ deltaH abs-dz-AUS abs-dz-EIN
|
||
(- bogen-z1) (- bogen-z2)
|
||
(* feste-hz sin3)))
|
||
(setq B (+ (- deltaH abs-dz-AUS abs-dz-EIN
|
||
(* feste-hz sin3))
|
||
bogen-z1 bogen-z2))
|
||
)
|
||
(if (> (abs sinα) 0.0001)
|
||
(progn
|
||
(setq L_GF (/ (- (* A sinEff) (* B cosEff)) sinα))
|
||
(if (= richtung "Auf")
|
||
(setq L_VF (/ (+ (* A sin3) (* B cos3)) sinα))
|
||
(setq L_VF (/ (- (* B cos3) (* A sin3)) sinα))
|
||
)
|
||
(if (and (numberp L_GF) (numberp L_VF))
|
||
(progn
|
||
(setq gueltig (and (>= L_GF 0) (>= L_VF 0)))
|
||
(setq ergebnis-liste
|
||
(cons (list winkel L_GF L_VF gueltig) ergebnis-liste))
|
||
)
|
||
(setq ergebnis-liste
|
||
(cons (list winkel nil nil nil) ergebnis-liste))
|
||
)
|
||
)
|
||
(setq ergebnis-liste (cons (list winkel nil nil nil) ergebnis-liste))
|
||
)
|
||
)
|
||
)
|
||
)
|
||
(setq ergebnis-liste (reverse ergebnis-liste))
|
||
|
||
(princ "\n\n=================================================================================")
|
||
(princ (ssg-text "vfs-ergebnistabelle-header"))
|
||
(princ "\n=================================================================================")
|
||
(princ (ssg-text "vfs-tabelle-spalten"))
|
||
(princ "\n=================================================================================")
|
||
|
||
(setq best-winkel nil best-L_GF nil best-L_VF nil)
|
||
(foreach item ergebnis-liste
|
||
(setq winkel (car item) L_GF (cadr item) L_VF (caddr item) gueltig (cadddr item))
|
||
(if (and (numberp L_GF) (numberp L_VF))
|
||
(progn
|
||
(princ (ssg-textf "vfs-tabelle-zeile"
|
||
(list (itoa winkel) (chr 176) (fmt L_GF) (fmt L_VF))))
|
||
(if gueltig
|
||
(progn
|
||
(princ (ssg-text "vfs-status-gueltig"))
|
||
(if (or (null best-winkel) (< winkel best-winkel))
|
||
(setq best-winkel winkel best-L_GF L_GF best-L_VF L_VF)
|
||
)
|
||
)
|
||
(princ (ssg-text "vfs-status-ungueltig"))
|
||
)
|
||
)
|
||
(princ (ssg-textf "vfs-tabelle-zeile-fehler" (list (itoa winkel) (chr 176))))
|
||
)
|
||
)
|
||
(princ "\n=================================================================================")
|
||
(if best-winkel
|
||
(princ (ssg-textf "vfs-empfohlener-winkel" (list (itoa best-winkel) (chr 176))))
|
||
(princ (ssg-text "vfs-kein-winkel-gefunden"))
|
||
)
|
||
(list best-winkel best-L_GF best-L_VF ergebnis-liste)
|
||
)
|
||
|
||
;; Prueft/berechnet die Variante mit HORIZONTALER Zwischenstrecke (Schritt
|
||
;; 6/11 bei 0 Grad statt geneigt). Die beiden Vertikalboegen sind dabei
|
||
;; IMMER auf 3 Grad fixiert (Vario_Bogen_auf_3 / Vario_Bogen_ab_3), weil sie
|
||
;; nur zwischen der festen 3-Grad-Neigung von Umlenk-/Motorstation und der
|
||
;; horizontalen Mitte vermitteln muessen - unabhaengig von Auf/Ab.
|
||
;; WICHTIG (geometrische Konsequenz): GF1+GF2 (an AS/ES-Seite, ebenfalls
|
||
;; fest bei 3 Grad geneigt) sind die einzige nennenswerte Quelle fuer
|
||
;; Hoehenaenderung, da sich die beiden Boegen gegenseitig fast vollstaendig
|
||
;; kompensieren. Die feste 3-Grad-Neigung wirkt IMMER absenkend:
|
||
;; - "Ab": passt zur gewuenschten Absenkung -> deltaH praktisch beliebig
|
||
;; erreichbar (im Rahmen von deltaL), GF1+GF2 werden einfach laenger.
|
||
;; - "Auf": wirkt der gewuenschten Steigung entgegen -> nur fuer SEHR
|
||
;; KLEINE deltaH ueberhaupt gueltig (wenige cm).
|
||
;; Rueckgabe: (GF_total L_VF gueltig) oder nil falls Boegen nicht messbar.
|
||
(defun berechne-horizontale-mitte (deltaL deltaH richtung /
|
||
mass1 mass2 rad3 bogen-x1 bogen-z1
|
||
bogen-x2 bogen-z2 deltaH-signiert
|
||
A-hz B-hz GF_total L_VF-hz gueltig)
|
||
(setq mass1 (get-bogen-mass bogen-auf 3))
|
||
(setq mass2 (get-bogen-mass bogen-ab 3))
|
||
(if (or (null mass1) (null mass2))
|
||
nil
|
||
(progn
|
||
(setq rad3 (* 3.0 (/ pi 180.0)))
|
||
;; Bogen1 (immer auf_3): Eintritt bei 3 Grad (von Umlenkstation), biegt auf 0 Grad
|
||
(setq bogen-x1 (+ (* (car mass1) (cos rad3)) (* (caddr mass1) (sin rad3))))
|
||
(setq bogen-z1 (+ (* (- (car mass1)) (sin rad3)) (* (caddr mass1) (cos rad3))))
|
||
;; Bogen2 (immer ab_3): Eintritt bei 0 Grad (von der horizontalen Mitte), biegt auf 3 Grad
|
||
(setq bogen-x2 (car mass2))
|
||
(setq bogen-z2 (caddr mass2))
|
||
;; Signierte Ziel-Hoehenaenderung: Auf=+deltaH, Ab=-deltaH
|
||
(setq deltaH-signiert (if (= richtung "Auf") deltaH (- deltaH)))
|
||
;; Horizontal-Budget: deltaL minus AS/ES minus beide Boegen minus feste Stationen (bei 3 Grad)
|
||
(setq A-hz (- deltaL aus-dx ein-dx bogen-x1 bogen-x2
|
||
(* FESTE_HORIZONTAL (cos rad3))))
|
||
;; Hoehen-Budget: was GF1+GF2 (bei 3 Grad) noch beitragen muessen
|
||
(setq B-hz (- (+ aus-dz ein-dz (- (* FESTE_HORIZONTAL (sin rad3)))
|
||
bogen-z1 bogen-z2)
|
||
deltaH-signiert))
|
||
(setq GF_total (/ B-hz (sin rad3)))
|
||
(setq L_VF-hz (- A-hz (* GF_total (cos rad3))))
|
||
(setq gueltig (and (>= GF_total 0) (>= L_VF-hz 0)))
|
||
(list GF_total L_VF-hz gueltig)
|
||
)
|
||
)
|
||
)
|
||
|
||
;; ============================================================
|
||
;; TEIL 5: BERECHNE-WRAPPER (Schnittstelle fuer Registry)
|
||
;; ============================================================
|
||
;; Initialisiert Standard-Bibliothek und berechnet Winkel.
|
||
;; seite-Parameter wird fuer Standard-Typ nicht benoetigt (keine Vorab-Geometrie).
|
||
;; Die Machbarkeitspruefung fuer die horizontale Zwischenstrecke passiert
|
||
;; separat und VORAB in c:VarioFoerderer (vor der Foerderrichtung-Abfrage),
|
||
;; deshalb liefert diese Funktion nur noch die normale Winkelsuche zurueck.
|
||
(defun berechne-standard (deltaL deltaH richtung seite)
|
||
(setq FESTE_HORIZONTAL (ssg-cfg-or "vario" "feste_horizontal" 1600))
|
||
(setq staustrecke-basis (ssg-cfg-or "vario" "staustrecke_basis" 1000))
|
||
(init-bibliothek)
|
||
(berechne-alle-winkel deltaL deltaH richtung nil)
|
||
)
|
||
|
||
;; ============================================================
|
||
;; TEIL 6: EINFUEGEN (11 Schritte, ohne VF_*-Block-Erstellung)
|
||
;; ============================================================
|
||
;; Gibt endpunkt zurueck (letzter KS_AUS nach ES_90).
|
||
;; VF_*-Block-Erstellung erfolgt zentral im Dispatcher (vf_core.lsp).
|
||
;; hz: horizontale Fahrtrichtung in Grad (0=Ost/+X, 90=Nord/+Y, 180=West/-X,
|
||
;; 270=Sued/-Y). Default 0, falls vom Aufrufer nicht mitgegeben (Etage-
|
||
;; Registry-Kompatibilitaet - siehe c:VarioFoerderer).
|
||
;; --- Teil 1/3: AS-Element (Kettenanfang) ---
|
||
;; Eigenstaendig, damit vf-linienzug (Gemischte GF/VF-Kette) ein VF-Segment
|
||
;; auch OHNE eigenes AS/ES mitten in der Kette einfuegen kann (vfs-mitte-teil
|
||
;; alleine), waehrend ein normaler Standard-VarioFoerderer weiterhin alle 3
|
||
;; Teile nacheinander durchlaeuft (siehe variofoerderer-einfuegen unten).
|
||
(defun vfs-as-teil (startpunkt seite hz / as-block)
|
||
(if (null hz) (setq hz 0.0))
|
||
(setq hz (float hz))
|
||
(setq as-block (strcat "AS_Element_90_" seite))
|
||
(if (not *lib-initialized*) (init-bibliothek))
|
||
(princ (ssg-textf "vfs-schritt-as" (list as-block (rtos hz 2 1) grad-zeichen)))
|
||
(insert-block-by-ks as-block startpunkt hz)
|
||
)
|
||
|
||
;; --- Teil 2a: VF-Eingang (GF1 + Separator + Umlenkstation) ---
|
||
;; Beginnt eine reine VF-Einheit: bringt die Kette von der (3-Grad-geneigten)
|
||
;; AS-Seite ueber GF1 + Separator bis zur Umlenkstation. Wird pro VF-Einheit
|
||
;; GENAU EINMAL aufgerufen (auch wenn danach mehrere Sub-Segmente folgen).
|
||
(defun vfs-vf-entry (aktueller-punkt L_GF1 hz)
|
||
(if (null hz) (setq hz 0.0))
|
||
(setq hz (float hz))
|
||
;; 1. Gefaellestrecke GF1 (verbindet AS-Neigung mit Umlenkstation)
|
||
(if (> L_GF1 0.1)
|
||
(progn
|
||
(princ (ssg-textf "vfs-vf-eingang-gf1" (list (rtos L_GF1 2 2))))
|
||
(setq aktueller-punkt
|
||
(insert-inclined-scaled-block "Staustrecke_SP_1000_mm" aktueller-punkt
|
||
L_GF1 (ssg-cfg-or "vario" "gefaelle_winkel" 3) hz))
|
||
)
|
||
(princ (ssg-text "vfs-vf-eingang-gf1-skip"))
|
||
)
|
||
;; 2. Separator (am GF1-Ende / vor Umlenkstation)
|
||
(princ (ssg-text "vfs-vf-eingang-separator"))
|
||
(setq aktueller-punkt
|
||
(insert-rotated-block-with-ks "Staustrecke_Separator_SP_300_mm" aktueller-punkt
|
||
(ssg-cfg-or "vario" "gefaelle_winkel" 3)
|
||
(ssg-cfg-or "vario" "separator_block_dx" 300)
|
||
(ssg-cfg-or "vario" "separator_block_dz" 0) hz))
|
||
;; 3. Umlenkstation
|
||
(princ (ssg-text "vfs-vf-eingang-umlenk"))
|
||
(setq aktueller-punkt
|
||
(insert-rotated-block-with-ks "Vario_Umlenkstation_500mm" aktueller-punkt
|
||
(ssg-cfg-or "vario" "gefaelle_winkel" 3)
|
||
(ssg-cfg-or "vario" "station_block_dx" 500)
|
||
(ssg-cfg-or "vario" "station_block_dz" 0) hz))
|
||
aktueller-punkt
|
||
)
|
||
|
||
;; --- Teil 2b: VF-Koerper (Vertikalbogen + L_VF + Vertikalbogen) ---
|
||
;; EIN reines VF-Sub-Segment. Wichtig: es BEGINNT und ENDET auf der
|
||
;; 3-Grad-Basisneigung, weil Ein- und Ausgangsbogen denselben Winkel haben.
|
||
;; Dadurch lassen sich mehrere Sub-Segmente (und Vario-Kurven dazwischen)
|
||
;; beliebig aneinanderreihen (siehe doc/VarioFoerderer_Linienzug_Prinzipien.md).
|
||
;; best-winkel=0 => horizontales Sub-Segment (Boegen fest auf_3/ab_3).
|
||
(defun vfs-vf-koerper (aktueller-punkt richtung best-winkel L_VF hz /
|
||
bogen-name bogen-mass bogen-dx bogen-dz)
|
||
(if (null hz) (setq hz 0.0))
|
||
(setq hz (float hz))
|
||
|
||
;; 5. 1. Vertikalbogen
|
||
;; Sonderfall best-winkel=0 (horizontale Zwischenstrecke, siehe
|
||
;; berechne-horizontale-mitte): Boegen IMMER auf_3/ab_3, unabhaengig von
|
||
;; Auf/Ab, da sie nur zwischen der festen 3-Grad-Neigung und der
|
||
;; horizontalen Mitte vermitteln muessen.
|
||
(if (= best-winkel 0)
|
||
(progn
|
||
(setq bogen-name "Vario_Bogen_auf_3")
|
||
(setq bogen-mass (get-bogen-mass bogen-auf 3))
|
||
)
|
||
(if (= richtung "Auf")
|
||
(progn
|
||
(setq bogen-name (strcat "Vario_Bogen_auf_" (itoa best-winkel)))
|
||
(setq bogen-mass (get-bogen-mass bogen-auf best-winkel))
|
||
)
|
||
(progn
|
||
(setq bogen-name (strcat "Vario_Bogen_ab_" (itoa best-winkel)))
|
||
(setq bogen-mass (get-bogen-mass bogen-ab best-winkel))
|
||
)
|
||
)
|
||
)
|
||
(setq bogen-dx (car bogen-mass) bogen-dz (caddr bogen-mass))
|
||
(princ (ssg-textf "vfs-schritt5-bogen1" (list bogen-name)))
|
||
(setq aktueller-punkt
|
||
(insert-rotated-block-with-ks bogen-name aktueller-punkt
|
||
(ssg-cfg-or "vario" "gefaelle_winkel" 3) bogen-dx bogen-dz hz))
|
||
|
||
;; 6. Variable Strecke L_VF
|
||
(if (> L_VF 0.1)
|
||
(progn
|
||
(if (= best-winkel 0)
|
||
(progn
|
||
(princ (strcat "\n\n6/11: Horizontale Zwischenstrecke (0 Grad, L="
|
||
(rtos L_VF 2 2) " mm)"))
|
||
(setq aktueller-punkt
|
||
(insert-inclined-scaled-block "Staustrecke_SP_1000_mm" aktueller-punkt
|
||
L_VF 0 hz))
|
||
)
|
||
(if (= richtung "Auf")
|
||
(progn
|
||
(princ (strcat "\n\n6/11: Steigungsstrecke ("
|
||
(itoa (- (- best-winkel 3))) " Grad, L=" (rtos L_VF 2 2) " mm)"))
|
||
(setq aktueller-punkt
|
||
(insert-inclined-scaled-block "Staustrecke_SP_1000_mm" aktueller-punkt
|
||
L_VF (- (- best-winkel 3)) hz))
|
||
)
|
||
(progn
|
||
(princ (strcat "\n\n6/11: Gefaellestrecke ("
|
||
(itoa (+ best-winkel 3)) " Grad, L=" (rtos L_VF 2 2) " mm)"))
|
||
(setq aktueller-punkt
|
||
(insert-inclined-scaled-block "Staustrecke_SP_1000_mm" aktueller-punkt
|
||
L_VF (+ best-winkel 3) hz))
|
||
)
|
||
)
|
||
)
|
||
)
|
||
(princ "\n\n6/11: (uebersprungen)")
|
||
)
|
||
|
||
;; 7. 2. Vertikalbogen
|
||
(if (= best-winkel 0)
|
||
(progn
|
||
(setq bogen-name "Vario_Bogen_ab_3")
|
||
(setq bogen-mass (get-bogen-mass bogen-ab 3))
|
||
)
|
||
(if (= richtung "Auf")
|
||
(progn
|
||
(setq bogen-name (strcat "Vario_Bogen_ab_" (itoa best-winkel)))
|
||
(setq bogen-mass (get-bogen-mass bogen-ab best-winkel))
|
||
)
|
||
(progn
|
||
(setq bogen-name (strcat "Vario_Bogen_auf_" (itoa best-winkel)))
|
||
(setq bogen-mass (get-bogen-mass bogen-auf best-winkel))
|
||
)
|
||
)
|
||
)
|
||
(setq bogen-dx (car bogen-mass) bogen-dz (caddr bogen-mass))
|
||
(if (= best-winkel 0)
|
||
(progn
|
||
(princ (strcat "\n\n7/11: " bogen-name " (3 Grad geneigt)"))
|
||
(setq aktueller-punkt
|
||
(insert-rotated-block-with-ks bogen-name aktueller-punkt
|
||
0 bogen-dx bogen-dz hz))
|
||
)
|
||
(if (= richtung "Auf")
|
||
(progn
|
||
(princ (strcat "\n\n7/11: " bogen-name
|
||
" (" (itoa (- 3 best-winkel)) " Grad geneigt)"))
|
||
(setq aktueller-punkt
|
||
(insert-rotated-block-with-ks bogen-name aktueller-punkt
|
||
(- 3 best-winkel) bogen-dx bogen-dz hz))
|
||
)
|
||
(progn
|
||
(princ (strcat "\n\n7/11: " bogen-name
|
||
" (" (itoa (+ best-winkel 3)) " Grad geneigt)"))
|
||
(setq aktueller-punkt
|
||
(insert-rotated-block-with-ks bogen-name aktueller-punkt
|
||
(+ best-winkel 3) bogen-dx bogen-dz hz))
|
||
)
|
||
)
|
||
)
|
||
|
||
aktueller-punkt
|
||
)
|
||
|
||
;; --- Teil 2c: VF-Ausgang (Motorstation [+ GF2] [+ Separator]) ---
|
||
;; Schliesst eine reine VF-Einheit mit der Motorstation.
|
||
;; L_GF2 > 0.1 => GF2 (3 Grad) wird angehaengt (verbindet Motorstation
|
||
;; mit der Auslauf-Neigung).
|
||
;; mit-separator T => Separator (300 mm) am Ende (Standard-VF: vor ES).
|
||
;; Standard-VF: L_GF2 = L_GF/2, mit-separator = t.
|
||
;; Linienzug: Separator wird NICHT hier gebaut (er sitzt erst vor dem ES bzw.
|
||
;; optional zwischen Foerderern) -> mit-separator = nil; GF2 je nach Wahl.
|
||
(defun vfs-vf-exit (aktueller-punkt L_GF2 hz mit-separator)
|
||
(if (null hz) (setq hz 0.0))
|
||
(setq hz (float hz))
|
||
;; Motorstation
|
||
(princ "\n\n[VF-Ausgang] Motorstation (500 mm, 3 Grad geneigt)")
|
||
(setq aktueller-punkt
|
||
(insert-rotated-block-with-ks "Vario_Motorstation_500mm" aktueller-punkt
|
||
(ssg-cfg-or "vario" "gefaelle_winkel" 3)
|
||
(ssg-cfg-or "vario" "station_block_dx" 500)
|
||
(ssg-cfg-or "vario" "station_block_dz" 0) hz))
|
||
;; GF2 (optional, verbindet Motorstation mit der Auslauf-Neigung)
|
||
(if (> L_GF2 0.1)
|
||
(progn
|
||
(princ (strcat "\n[VF-Ausgang] Gefaellestrecke GF2 (3 Grad, L=" (rtos L_GF2 2 2) " mm)"))
|
||
(setq aktueller-punkt
|
||
(insert-inclined-scaled-block "Staustrecke_SP_1000_mm" aktueller-punkt
|
||
L_GF2 (ssg-cfg-or "vario" "gefaelle_winkel" 3) hz))
|
||
)
|
||
(princ "\n[VF-Ausgang] GF2 (kein / uebersprungen)")
|
||
)
|
||
;; Separator (optional, nur Standard-VF)
|
||
(if mit-separator
|
||
(progn
|
||
(princ "\n[VF-Ausgang] Separator (300 mm, 3 Grad geneigt)")
|
||
(setq aktueller-punkt
|
||
(insert-rotated-block-with-ks "Staustrecke_Separator_SP_300_mm" aktueller-punkt
|
||
(ssg-cfg-or "vario" "gefaelle_winkel" 3)
|
||
(ssg-cfg-or "vario" "separator_block_dx" 300)
|
||
(ssg-cfg-or "vario" "separator_block_dz" 0) hz))
|
||
)
|
||
)
|
||
aktueller-punkt
|
||
)
|
||
|
||
;; --- Teil 2 (Zusammensetzung): Kettenmitte fuer den Standard-VF ---
|
||
;; Entry + EIN Koerper + Exit. Verhalten identisch zur bisherigen Fassung.
|
||
(defun vfs-mitte-teil (aktueller-punkt richtung best-winkel L_GF1 L_GF2 L_VF hz)
|
||
(if (null hz) (setq hz 0.0))
|
||
(setq hz (float hz))
|
||
(setq aktueller-punkt (vfs-vf-entry aktueller-punkt L_GF1 hz))
|
||
(setq aktueller-punkt (vfs-vf-koerper aktueller-punkt richtung best-winkel L_VF hz))
|
||
(setq aktueller-punkt (vfs-vf-exit aktueller-punkt L_GF2 hz t))
|
||
aktueller-punkt
|
||
)
|
||
|
||
;; --- Teil 3/3: ES-Element (Kettenende) ---
|
||
(defun vfs-es-teil (aktueller-punkt seite hz / es-block)
|
||
(if (null hz) (setq hz 0.0))
|
||
(setq hz (float hz))
|
||
(setq es-block (strcat "ES_Element_90_" seite))
|
||
(princ (strcat "\n\n11/11: " es-block " (hz=" (rtos hz 2 1) grad-zeichen ")"))
|
||
(insert-block-by-ks es-block aktueller-punkt hz)
|
||
)
|
||
|
||
;; --- Zusammensetzung: kompletter Standard-VarioFoerderer ---
|
||
;; Reine Verkettung von Teil 1+2+3, Verhalten identisch zur bisherigen
|
||
;; monolithischen Fassung. deltaL/deltaH werden hier nicht gebraucht (Teil
|
||
;; der einfuege-fn-Schnittstelle der Typ-Registry, siehe vf-typ-registrieren).
|
||
(defun variofoerderer-einfuegen (deltaL deltaH richtung best-winkel
|
||
L_GF1 L_GF2 L_VF startpunkt seite hz
|
||
/ aktueller-punkt endpunkt)
|
||
(if (null hz) (setq hz 0.0))
|
||
(setq hz (float hz))
|
||
(setq aktueller-punkt (vfs-as-teil startpunkt seite hz))
|
||
(setq aktueller-punkt
|
||
(vfs-mitte-teil aktueller-punkt richtung best-winkel L_GF1 L_GF2 L_VF hz))
|
||
(setq endpunkt (vfs-es-teil aktueller-punkt seite hz))
|
||
|
||
(princ "\n\n=========================================")
|
||
(princ "\n>>> Standard VarioFoerderer eingefuegt!")
|
||
endpunkt
|
||
)
|
||
|
||
;; ============================================================
|
||
;; DCL-DIALOG (Standardfall) - dcl/variofoerderer.dcl
|
||
;; Ersetzt die interaktive Werteingabe aus vf-eingabe-abfragen
|
||
;; (Konsolen-Modus "Werteingabe") fuer anlage-typ "standard" durch
|
||
;; zwei DCL-Dialoge: Basis-Eingabe und Winkel/Verteilung. Die
|
||
;; 3D-Linie-Eingabe sowie die Typen "etage"/"linienzug" bleiben
|
||
;; unveraendert interaktiv (siehe Verzweigung in c:VarioFoerderer).
|
||
;; ============================================================
|
||
|
||
;; Basis-Eingabe (Dialog 1): deltaL, deltaH, Richtung, Einfuegehoehe,
|
||
;; Fahrtrichtung, Seite.
|
||
;; prefill: Assoziationsliste zur Vorbelegung (fuer VARIOFOERDERER_EDIT) mit
|
||
;; Schluesseln "deltaL" "deltaH" "richtung" "einfuegehoehe" "hz" "seite"
|
||
;; - oder nil fuer Neuanlage mit Defaults.
|
||
;; Rueckgabe: (deltaL deltaH richtung einfuegehoehe hz seite) oder nil bei Abbruch.
|
||
(defun vfs-dialog-eingabe-basis (prefill / dcl-pfad dat ergebnis
|
||
dlg-deltal dlg-deltah dlg-richtung dlg-hoehe
|
||
dlg-fahrtrichtung dlg-seite
|
||
deltaL deltaH richtung hz seite z-start)
|
||
(setq dcl-pfad (strcat (getenv "DXFM_DCL") "/variofoerderer.dcl"))
|
||
(setq dat (load_dialog dcl-pfad))
|
||
(if (not (new_dialog "variofoerderer_basis" dat))
|
||
(progn
|
||
(if (>= dat 0) (unload_dialog dat))
|
||
(alert (ssg-textf "gf-alert-dialog-fehlt" (list dcl-pfad)))
|
||
nil
|
||
)
|
||
(progn
|
||
;; Vorbelegung: aus prefill (Edit) oder Defaults (Neuanlage)
|
||
(set_tile "deltal"
|
||
(if prefill (rtos (cdr (assoc "deltaL" prefill)) 2 0) "15000"))
|
||
(set_tile "deltah"
|
||
(if prefill (rtos (cdr (assoc "deltaH" prefill)) 2 0) "3000"))
|
||
(set_tile "einfuegehoehe"
|
||
(if prefill (rtos (cdr (assoc "einfuegehoehe" prefill)) 2 1) "0"))
|
||
|
||
(start_list "richtung")
|
||
(add_list (ssg-text "vfs-dlg-richtung-auf"))
|
||
(add_list (ssg-text "vfs-dlg-richtung-ab"))
|
||
(end_list)
|
||
(set_tile "richtung"
|
||
(if (and prefill (equal (cdr (assoc "richtung" prefill)) "Ab")) "1" "0"))
|
||
|
||
(start_list "fahrtrichtung")
|
||
(add_list (ssg-textf "gf-dlg-richtung-0" (list grad-zeichen)))
|
||
(add_list (ssg-textf "gf-dlg-richtung-90" (list grad-zeichen)))
|
||
(add_list (ssg-textf "gf-dlg-richtung-180" (list grad-zeichen)))
|
||
(add_list (ssg-textf "gf-dlg-richtung-270" (list grad-zeichen)))
|
||
(end_list)
|
||
(set_tile "fahrtrichtung"
|
||
(if prefill
|
||
(cond ((equal (cdr (assoc "hz" prefill)) 90.0 0.1) "1")
|
||
((equal (cdr (assoc "hz" prefill)) 180.0 0.1) "2")
|
||
((equal (cdr (assoc "hz" prefill)) 270.0 0.1) "3")
|
||
(t "0"))
|
||
"0"))
|
||
|
||
(start_list "seite")
|
||
(add_list (ssg-text "gf-dlg-rechts"))
|
||
(add_list (ssg-text "gf-dlg-links"))
|
||
(end_list)
|
||
(set_tile "seite"
|
||
(if (and prefill (equal (cdr (assoc "seite" prefill)) "links")) "1" "0"))
|
||
|
||
;; Actions
|
||
(action_tile "accept"
|
||
(strcat
|
||
"(setq dlg-deltal (get_tile \"deltal\"))"
|
||
"(setq dlg-deltah (get_tile \"deltah\"))"
|
||
"(setq dlg-richtung (get_tile \"richtung\"))"
|
||
"(setq dlg-hoehe (get_tile \"einfuegehoehe\"))"
|
||
"(setq dlg-fahrtrichtung (get_tile \"fahrtrichtung\"))"
|
||
"(setq dlg-seite (get_tile \"seite\"))"
|
||
"(done_dialog 1)"
|
||
)
|
||
)
|
||
(action_tile "cancel" "(done_dialog 0)")
|
||
|
||
(setq ergebnis (start_dialog))
|
||
(unload_dialog dat)
|
||
|
||
(if (= ergebnis 1)
|
||
(progn
|
||
(setq deltaL (atof dlg-deltal))
|
||
(setq deltaH (atof dlg-deltah))
|
||
(setq richtung (if (= dlg-richtung "1") "Ab" "Auf"))
|
||
(setq z-start (atof dlg-hoehe))
|
||
(setq hz
|
||
(cond ((= dlg-fahrtrichtung "1") 90.0)
|
||
((= dlg-fahrtrichtung "2") 180.0)
|
||
((= dlg-fahrtrichtung "3") 270.0)
|
||
(t 0.0)))
|
||
(setq seite (if (= dlg-seite "1") "links" "rechts"))
|
||
(list deltaL deltaH richtung z-start hz seite)
|
||
)
|
||
nil
|
||
)
|
||
)
|
||
)
|
||
)
|
||
|
||
;; Winkel/Verteilung-Eingabe (Dialog 2): Winkel-Popup aus den vorher
|
||
;; berechneten gueltigen Varianten (gueltige-winkel/ergebnis-liste, siehe
|
||
;; berechne-alle-winkel), plus L_GF-Verteilung vorne/hinten (analog Schritt
|
||
;; 8+9 in c:VarioFoerderer).
|
||
;; prefill: Assoziationsliste ("winkel" . best-winkel) ("verteilung-idx" . "0".."3")
|
||
;; ("lgf1" . mm) - oder nil fuer Vorbelegung mit dem kleinsten gueltigen Winkel.
|
||
;; Rueckgabe: (best-winkel L_GF L_VF L_GF1 L_GF2 verteilung-modus) oder nil bei Abbruch.
|
||
(defun vfs-dialog-winkel-verteilung (gueltige-winkel ergebnis-liste staustrecke-basis prefill /
|
||
dcl-pfad dat ergebnis w eintrag idx sel-idx init-verteilung
|
||
dlg-winkel dlg-verteilung dlg-lgf1
|
||
best-winkel L_GF L_VF verteilung-modus L_GF1 L_GF2)
|
||
(setq dcl-pfad (strcat (getenv "DXFM_DCL") "/variofoerderer.dcl"))
|
||
(setq dat (load_dialog dcl-pfad))
|
||
(if (not (new_dialog "variofoerderer_winkel" dat))
|
||
(progn
|
||
(if (>= dat 0) (unload_dialog dat))
|
||
(alert (ssg-textf "gf-alert-dialog-fehlt" (list dcl-pfad)))
|
||
nil
|
||
)
|
||
(progn
|
||
;; Winkel-Popup aus den gueltigen Varianten aufbauen
|
||
(start_list "winkel")
|
||
(foreach w gueltige-winkel
|
||
(setq eintrag (assoc w ergebnis-liste))
|
||
(if (= w 0)
|
||
(add_list (ssg-textf "vfs-dlg-winkel-horizontal"
|
||
(list (rtos (nth 1 eintrag) 2 1) (rtos (nth 2 eintrag) 2 1))))
|
||
(add_list (ssg-textf "vfs-dlg-winkel-option"
|
||
(list (itoa w) grad-zeichen (rtos (nth 1 eintrag) 2 1) (rtos (nth 2 eintrag) 2 1))))
|
||
)
|
||
)
|
||
(end_list)
|
||
;; Vorbelegung: Winkel aus prefill (falls noch gueltig), sonst erster
|
||
;; (kleinster) gueltiger Winkel - analog der automatischen Konsolen-Wahl.
|
||
(setq sel-idx 0 idx 0)
|
||
(if prefill
|
||
(foreach w gueltige-winkel
|
||
(if (equal w (cdr (assoc "winkel" prefill))) (setq sel-idx idx))
|
||
(setq idx (1+ idx))
|
||
)
|
||
)
|
||
(set_tile "winkel" (itoa sel-idx))
|
||
|
||
;; Verteilung: Popup + manuelles L_GF1-Feld (nur bei "Eigene Werte" aktiv)
|
||
(start_list "verteilung")
|
||
(add_list (ssg-text "vfs-dlg-verteilung-1"))
|
||
(add_list (ssg-text "vfs-dlg-verteilung-2"))
|
||
(add_list (ssg-text "vfs-dlg-verteilung-3"))
|
||
(add_list (ssg-text "vfs-dlg-verteilung-4"))
|
||
(end_list)
|
||
(setq init-verteilung (if prefill (cdr (assoc "verteilung-idx" prefill)) "0"))
|
||
(set_tile "verteilung" init-verteilung)
|
||
(set_tile "lgf1_manuell"
|
||
(if (and prefill (cdr (assoc "lgf1" prefill)))
|
||
(rtos (cdr (assoc "lgf1" prefill)) 2 1) "0"))
|
||
(mode_tile "lgf1_manuell" (if (= init-verteilung "3") 0 1))
|
||
|
||
(action_tile "verteilung"
|
||
"(mode_tile \"lgf1_manuell\" (if (= (get_tile \"verteilung\") \"3\") 0 1))")
|
||
|
||
(action_tile "accept"
|
||
(strcat
|
||
"(setq dlg-winkel (get_tile \"winkel\"))"
|
||
"(setq dlg-verteilung (get_tile \"verteilung\"))"
|
||
"(setq dlg-lgf1 (get_tile \"lgf1_manuell\"))"
|
||
"(done_dialog 1)"
|
||
)
|
||
)
|
||
(action_tile "cancel" "(done_dialog 0)")
|
||
|
||
(setq ergebnis (start_dialog))
|
||
(unload_dialog dat)
|
||
|
||
(if (= ergebnis 1)
|
||
(progn
|
||
(setq best-winkel (nth (atoi dlg-winkel) gueltige-winkel))
|
||
(setq eintrag (assoc best-winkel ergebnis-liste))
|
||
(setq L_GF (nth 1 eintrag) L_VF (nth 2 eintrag))
|
||
(setq verteilung-modus dlg-verteilung)
|
||
(cond
|
||
((= verteilung-modus "0")
|
||
(setq L_GF1 (/ L_GF 2.0) L_GF2 (/ L_GF 2.0)))
|
||
((= verteilung-modus "1")
|
||
(setq L_GF1 (float staustrecke-basis))
|
||
(setq L_GF2 (max 0.0 (- L_GF (float staustrecke-basis)))))
|
||
((= verteilung-modus "2")
|
||
(setq L_GF2 (float staustrecke-basis))
|
||
(setq L_GF1 (max 0.0 (- L_GF (float staustrecke-basis)))))
|
||
((= verteilung-modus "3")
|
||
(setq L_GF1 (atof dlg-lgf1))
|
||
(if (or (null L_GF1) (< L_GF1 0)) (setq L_GF1 (/ L_GF 2.0)))
|
||
(if (> L_GF1 L_GF) (setq L_GF1 L_GF))
|
||
(setq L_GF2 (max 0.0 (- L_GF L_GF1))))
|
||
(t (setq L_GF1 (/ L_GF 2.0) L_GF2 (/ L_GF 2.0)))
|
||
)
|
||
(list best-winkel L_GF L_VF L_GF1 L_GF2 verteilung-modus)
|
||
)
|
||
nil
|
||
)
|
||
)
|
||
)
|
||
)
|
||
|
||
;; ============================================================
|
||
;; XDATA-Metadaten fuer den Edit-Nachbau (App "SSG_VF_EDIT").
|
||
;; Markiert ein VF_n-INSERT als "mit dem Standard-Dialog erstellt" und
|
||
;; speichert die Fahrtrichtung (hz) - der einzige Wert, der sich nicht aus
|
||
;; den Sivas-Attributen rekonstruieren laesst (ANTRIEBFAHRTRICHTUNG, SEITE_AS,
|
||
;; VF_WINKEL, L_GF_m stehen dort bereits). Bewusst NICHT im Sivas-Attributsatz.
|
||
;; Ohne diese Markierung (z.B. Etage-, Linienzug- oder Altbestand-Bloecke)
|
||
;; verweigert c:VARIOFOERDERER_EDIT die Bearbeitung, um deren komplexere
|
||
;; Geometrie nicht versehentlich durch einen einfachen Neuaufbau zu ersetzen.
|
||
;; ============================================================
|
||
(if (null *vf-xdata-app*) (setq *vf-xdata-app* "SSG_VF_EDIT"))
|
||
|
||
(defun vfs-xdata-schreiben (ent hz /)
|
||
(regapp *vf-xdata-app*)
|
||
(entmod
|
||
(append (entget ent)
|
||
(list
|
||
(list -3
|
||
(list *vf-xdata-app*
|
||
(cons 1000 "standard")
|
||
(cons 1000 (rtos (float hz) 2 4)))))))
|
||
ent
|
||
)
|
||
|
||
;; XDATA lesen -> (typ-marker hz-str) oder nil.
|
||
(defun vfs-xdata-lesen (ent / xd app-data)
|
||
(setq xd (entget ent (list *vf-xdata-app*)))
|
||
(setq app-data (cdr (assoc -3 xd)))
|
||
(if app-data
|
||
(mapcar 'cdr (cdr (car app-data)))
|
||
nil
|
||
)
|
||
)
|
||
|
||
;; ============================================================
|
||
;; Gemeinsame Berechnung + Winkel/Verteilung-Dialog + Einfuegung.
|
||
;; Wird sowohl von der Neuanlage (vfs-standard-dialog-ablauf) als auch vom
|
||
;; Edit-Befehl (c:VARIOFOERDERER_EDIT) verwendet.
|
||
;; winkel-prefill: Vorbelegung fuer vfs-dialog-winkel-verteilung oder nil.
|
||
;; ============================================================
|
||
(defun vfs-standard-dialog-berechnen-einfuegen (vf-nummer deltaL deltaH richtung startpunkt hz seite
|
||
winkel-prefill /
|
||
ergebnis ergebnis-liste gueltige-winkel horizontal-info
|
||
winkelwahl best-winkel L_GF L_VF L_GF1 L_GF2 verteilung-modus
|
||
n-scanner hoehe-von hoehe-bis lastEnt vf-insert staustrecke-basis)
|
||
(setq ergebnis (berechne-standard deltaL deltaH richtung seite))
|
||
(setq ergebnis-liste (cadddr ergebnis))
|
||
(setq staustrecke-basis (ssg-cfg-or "vario" "staustrecke_basis" 1000))
|
||
|
||
;; Horizontale Zwischenstrecke als Zusatzoption (nur bei "Ab" erreichbar,
|
||
;; siehe Kommentar in c:VarioFoerderer Schritt 5b).
|
||
(setq horizontal-info nil)
|
||
(if (= richtung "Ab")
|
||
(progn
|
||
(setq horizontal-info (berechne-horizontale-mitte deltaL deltaH "Ab"))
|
||
(if (and horizontal-info (caddr horizontal-info))
|
||
(setq ergebnis-liste
|
||
(append ergebnis-liste (list (list 0 (car horizontal-info) (cadr horizontal-info) T))))
|
||
(setq horizontal-info nil)
|
||
)
|
||
)
|
||
)
|
||
|
||
(setq gueltige-winkel
|
||
(mapcar 'car
|
||
(vl-remove-if-not
|
||
(function (lambda (e) (and (nth 3 e) (numberp (nth 1 e)) (numberp (nth 2 e))
|
||
(>= (nth 1 e) 0) (>= (nth 2 e) 0))))
|
||
ergebnis-liste)))
|
||
|
||
(if (null gueltige-winkel)
|
||
(alert (ssg-textf "vfc-alert-kein-winkel"
|
||
(list (chr 916) (rtos deltaL 2 0) (rtos deltaH 2 0) richtung)))
|
||
(progn
|
||
(setq winkelwahl (vfs-dialog-winkel-verteilung gueltige-winkel ergebnis-liste staustrecke-basis winkel-prefill))
|
||
(if (null winkelwahl)
|
||
(princ (ssg-text "vfc-vorgang-abgebrochen"))
|
||
(progn
|
||
(setq best-winkel (nth 0 winkelwahl)
|
||
L_GF (nth 1 winkelwahl)
|
||
L_VF (nth 2 winkelwahl)
|
||
L_GF1 (nth 3 winkelwahl)
|
||
L_GF2 (nth 4 winkelwahl)
|
||
verteilung-modus (nth 5 winkelwahl))
|
||
(setq n-scanner 0)
|
||
(setq hoehe-von (caddr startpunkt))
|
||
(setq hoehe-bis
|
||
(cond ((= richtung "Auf") (+ hoehe-von deltaH))
|
||
((= richtung "Ab") (- hoehe-von deltaH))
|
||
(t hoehe-von)))
|
||
(setq lastEnt (vf-lastent-ohne-attribute))
|
||
|
||
(variofoerderer-einfuegen deltaL deltaH richtung best-winkel L_GF1 L_GF2 L_VF startpunkt seite hz)
|
||
|
||
(setq vf-insert
|
||
(vf-block-erstellen "standard" seite vf-nummer n-scanner
|
||
hoehe-von hoehe-bis deltaH deltaL L_VF L_GF1 L_GF2
|
||
richtung best-winkel startpunkt lastEnt hz))
|
||
(if vf-insert (vfs-xdata-schreiben vf-insert hz))
|
||
(princ "\n=========================================")
|
||
)
|
||
)
|
||
)
|
||
)
|
||
)
|
||
|
||
;; Neuanlage (Menue/Konsole -> Dialog): Startpunkt (X/Y) picken, Basis-Dialog,
|
||
;; dann gemeinsame Berechnung/Winkel-Dialog/Einfuegung.
|
||
(defun vfs-standard-dialog-ablauf (vf-nummer / eingabe deltaL deltaH richtung
|
||
z-start hz seite startpunkt startpunkt-xy)
|
||
(setq startpunkt-xy (getpoint (ssg-text "vfc-prompt-startpunkt-aus")))
|
||
(if (null startpunkt-xy) (setq startpunkt-xy '(0 0 0)))
|
||
|
||
(setq eingabe (vfs-dialog-eingabe-basis nil))
|
||
(if (null eingabe)
|
||
(princ (ssg-text "vfc-vorgang-abgebrochen"))
|
||
(progn
|
||
(setq deltaL (nth 0 eingabe)
|
||
deltaH (nth 1 eingabe)
|
||
richtung (nth 2 eingabe)
|
||
z-start (nth 3 eingabe)
|
||
hz (nth 4 eingabe)
|
||
seite (nth 5 eingabe))
|
||
(setq startpunkt (list (car startpunkt-xy) (cadr startpunkt-xy) z-start))
|
||
(vfs-standard-dialog-berechnen-einfuegen vf-nummer deltaL deltaH richtung startpunkt hz seite nil)
|
||
)
|
||
)
|
||
)
|
||
|
||
;; ============================================================
|
||
;; VARIOFOERDERER_EDIT - Doppelklick/Kontextmenue-Bearbeitung
|
||
;; ============================================================
|
||
|
||
;; Bearbeitet einen bestehenden Standard-VarioFoerderer (VF_n-Block, mit
|
||
;; SSG_VF_EDIT-XDATA) ueber die DCL-Dialoge: liest die aktuellen Parameter,
|
||
;; zeigt sie vorbelegt und baut die Strecke bei OK am selben Startpunkt neu
|
||
;; auf. Wird vom Doppelklick-Dispatcher SSG_BLOCKEDIT fuer Blocknamen "VF_*"
|
||
;; aufgerufen. Bloecke ohne SSG_VF_EDIT-XDATA (Etage, Linienzug, Altbestand)
|
||
;; werden abgewiesen, da ihre Geometrie sich nicht verlustfrei aus dem
|
||
;; einfachen Standard-Schema rekonstruieren laesst.
|
||
(defun c:VARIOFOERDERER_EDIT ( / ss ent ed bname startpunkt attribs xd
|
||
deltaL deltaH richtung z-start hz seite
|
||
eingabe vf-nummer best-winkel-attr L_GF_m-teile
|
||
prefill-basis prefill-winkel)
|
||
;; Implied Selection VOR ssg-start pruefen (ssg-start hebt Selektion auf)
|
||
(setq ss (ssget "I"))
|
||
(if (and ss (= (sslength ss) 1)
|
||
(= (cdr (assoc 0 (entget (ssname ss 0)))) "INSERT"))
|
||
(setq ent (ssname ss 0))
|
||
)
|
||
|
||
(ssg-start "VARIOFOERDERER_EDIT" '(("OSMODE") ("ATTREQ") ("ATTDIA")))
|
||
(setvar "OSMODE" 0)
|
||
|
||
(if (null ent)
|
||
(progn
|
||
(setq ss (ssget ":S" '((0 . "INSERT"))))
|
||
(if ss (setq ent (ssname ss 0)))
|
||
)
|
||
)
|
||
(if (null ent) (progn (ssg-end) (exit)))
|
||
|
||
(setq ed (entget ent))
|
||
(setq bname (cdr (assoc 2 ed)))
|
||
(if (not (wcmatch bname "VF_*"))
|
||
(progn (alert (ssg-textf "vfs-edit-kein-vf" (list bname))) (ssg-end) (exit)))
|
||
|
||
(setq xd (vfs-xdata-lesen ent))
|
||
(if (or (null xd) (/= (car xd) "standard"))
|
||
(progn (alert (ssg-textf "vfs-edit-keine-xdata" (list bname))) (ssg-end) (exit)))
|
||
|
||
(setq startpunkt (cdr (assoc 10 ed)))
|
||
(setq attribs (ssg-attrib-read ent))
|
||
(setq hz (atof (nth 1 xd)))
|
||
(setq deltaL (atof (cond ((cdr (assoc "DELTA_L_mm" attribs))) ("15000"))))
|
||
(setq deltaH (atof (cond ((cdr (assoc "DELTA_H_mm" attribs))) ("3000"))))
|
||
(setq richtung (cond ((cdr (assoc "ANTRIEBFAHRTRICHTUNG" attribs))) ("Auf")))
|
||
(setq seite (cond ((cdr (assoc "SEITE_AS" attribs))) ("rechts")))
|
||
(setq z-start (caddr startpunkt))
|
||
|
||
(setq prefill-basis
|
||
(list (cons "deltaL" deltaL) (cons "deltaH" deltaH) (cons "richtung" richtung)
|
||
(cons "einfuegehoehe" z-start) (cons "hz" hz) (cons "seite" seite)))
|
||
|
||
(setq eingabe (vfs-dialog-eingabe-basis prefill-basis))
|
||
(if (null eingabe)
|
||
(princ (ssg-text "vfc-vorgang-abgebrochen"))
|
||
(progn
|
||
(setq deltaL (nth 0 eingabe)
|
||
deltaH (nth 1 eingabe)
|
||
richtung (nth 2 eingabe)
|
||
z-start (nth 3 eingabe)
|
||
hz (nth 4 eingabe)
|
||
seite (nth 5 eingabe))
|
||
(setq startpunkt (list (car startpunkt) (cadr startpunkt) z-start))
|
||
|
||
;; Vorbelegung Winkel/Verteilung: bestehenden Winkel vorschlagen, L_GF-
|
||
;; Verteilung als "Eigene Werte" mit dem aktuellen L_GF1 (aus L_GF_m) -
|
||
;; das ist unabhaengig vom urspruenglichen Verteilungsmodus immer exakt.
|
||
(setq best-winkel-attr (atoi (cond ((cdr (assoc "VF_WINKEL" attribs))) ("0"))))
|
||
(setq L_GF_m-teile (ssg-cfg-split-comma (cond ((cdr (assoc "L_GF_m" attribs))) ("0.0,0.0"))))
|
||
(setq prefill-winkel
|
||
(list (cons "winkel" best-winkel-attr)
|
||
(cons "verteilung-idx" "3")
|
||
(cons "lgf1" (* 1000.0 (atof (car L_GF_m-teile))))))
|
||
|
||
(entdel ent)
|
||
(setq vf-nummer (vf-next-number))
|
||
(vfs-standard-dialog-berechnen-einfuegen vf-nummer deltaL deltaH richtung
|
||
startpunkt hz seite prefill-winkel)
|
||
(princ (ssg-textf "vfs-edit-neu-aufgebaut" (list bname)))
|
||
)
|
||
)
|
||
(ssg-end)
|
||
(princ)
|
||
)
|
||
|
||
;; ============================================================
|
||
;; REGISTRIERUNG
|
||
;; ============================================================
|
||
(vf-typ-registrieren
|
||
"standard"
|
||
'berechne-standard
|
||
'variofoerderer-einfuegen
|
||
"Standard VarioFoerderer (AS/ES 90 Grad, horizontal versetzt)")
|
||
|
||
(princ "\n>>> vf_standard.lsp geladen - Typ 'standard' registriert")
|
||
(princ)
|