;; ============================================================ ;; Gefaellestrecke.lsp - Gefaelle-Foerderanlage Generator ;; ;; Erzeugt eine einfache Foerderanlage mit festem Gefaellewinkel: ;; AUS-Element → Staustrecke_SP_1000_mm (skaliert) → ;; Staustrecke_Separator_SP_300_mm → EIN-Element ;; ;; Abhaengigkeiten (aus VarioFoerderer.lsp, muss vorher geladen sein): ;; block-pfad, aus-dx, ein-dx, *lib-initialized*, grad-zeichen ;; init-bibliothek, ensure-block-loaded ;; insert-block-by-ks, insert-inclined-scaled-block ;; insert-rotated-block-with-ks, get-line-start-end-points ;; punkt-differenz ;; ;; Befehl: GEFAELLESTRECKE ;; ============================================================ ;; ============================================================ ;; TEIL 1: EINFUEGE-FUNKTION ;; ============================================================ (defun gefaellestrecke-einfuegen (L_stau winkel startpunkt seite / aktueller-punkt as-block es-block tilt-winkel endpunkt) (setq aktueller-punkt startpunkt) (setq as-block (strcat "_3D_AS_90_" seite)) (setq es-block (strcat "_3D_ES_90_" seite)) ;; Richtung immer Ab (abwaerts) – positiver Winkel = Gefaelle nach unten (setq tilt-winkel winkel) (if (not *lib-initialized*) (init-bibliothek)) ;; 1/4 AUS-Element (princ (strcat "\n\n1/4: " as-block " (0°)")) (setq aktueller-punkt (insert-block-by-ks as-block aktueller-punkt)) ;; 2/4 Staustrecke_SP_1000_mm (skaliert) (princ (strcat "\n\n2/4: Staustrecke_SP_1000_mm (" (itoa winkel) grad-zeichen ", Laenge=" (rtos L_stau 2 2) " mm)")) (setq aktueller-punkt (insert-inclined-scaled-block "Staustrecke_SP_1000_mm" aktueller-punkt L_stau tilt-winkel)) ;; 3/4 Staustrecke_Separator_SP_300_mm (princ (strcat "\n\n3/4: Staustrecke_Separator_SP_300_mm (" (itoa winkel) grad-zeichen ")")) (setq aktueller-punkt (insert-rotated-block-with-ks "Staustrecke_Separator_SP_300_mm" aktueller-punkt tilt-winkel 300 0)) ;; 4/4 EIN-Element (princ (strcat "\n\n4/4: " es-block " (0°)")) (setq endpunkt (insert-block-by-ks es-block aktueller-punkt)) (princ "\n\n=========================================") (princ "\n>>> Gefaellestrecke erfolgreich eingefuegt! <<<") (princ "\n=========================================") endpunkt ) ;; ============================================================ ;; TEIL 2: HAUPTFUNKTION ;; ============================================================ (defun c:GEFAELLESTRECKE ( / deltaL winkel rad L_stau sep-x antwort seite eingabe-modus line-points startpunkt endpunkt differenz deltaX deltaY startpunkt-fuer-einfuegen) (princ "\n=========================================") (princ "\n GEFAELLESTRECKE GENERATOR v1.0") (princ "\n Richtung: immer AB (nach unten)") (princ "\n=========================================") ;; Bibliothek initialisieren (aus VarioFoerderer.lsp) (if (not (init-bibliothek)) (progn (alert "Fehler beim Initialisieren der Bibliothek!\nBitte Pfade pruefen.") (exit) ) ) ;; --- Eingabemodus --- (princ "\n\nEingabemodus waehlen:") (princ "\n 1 - Werte manuell eingeben") (princ "\n 2 - 3D-Linie auswaehlen (Start- und Endpunkt mit Hoehe)") (setq antwort (getstring "\nIhre Wahl (1/2) [1]: ")) (if (= antwort "2") (setq eingabe-modus "Linie") (setq eingabe-modus "Manuell") ) ;; --- Modus 1: Manuelle Eingabe --- (if (= eingabe-modus "Manuell") (progn (princ "\n\n>>> MODUS: Manuelle Werteingabe <<<") (setq startpunkt-fuer-einfuegen (getpoint "\nStartpunkt fuer AUS_Element waehlen: ")) (if (null startpunkt-fuer-einfuegen) (setq startpunkt-fuer-einfuegen '(0 0 0))) (setq deltaL (getreal "\nAbstand ΔL (mm): ")) (if (or (null deltaL) (<= deltaL 0)) (setq deltaL (ssg-cfg-or "gefaelle" "default_delta_l" 5000.0))) ) ;; --- Modus 2: 3D-Linie --- (progn (princ "\n\n>>> MODUS: 3D-Linie auswaehlen <<<") (command "BKS" "W") (princ "\n ✓ BKS auf Weltkoordinaten gesetzt") (setq line-points (get-line-start-end-points "\nBitte 3D-Linie fuer die Gefaellestrecke auswaehlen:")) (if (null line-points) (progn (alert "Keine gueltige Linie ausgewaehlt!") (exit)) ) (setq startpunkt (car line-points)) (setq endpunkt (cadr line-points)) (setq differenz (punkt-differenz startpunkt endpunkt)) (setq deltaX (abs (car differenz))) (setq deltaY (abs (cadr differenz))) (setq deltaL (max deltaX deltaY)) (princ (strcat "\n → ΔX=" (rtos deltaX 2 2) " mm, ΔY=" (rtos deltaY 2 2) " mm")) (princ (strcat "\n → ΔL = " (rtos deltaL 2 2) " mm")) (setq startpunkt-fuer-einfuegen startpunkt) ) ) (princ "\n\n=========================================") (princ (strcat "\n ΔL = " (rtos deltaL 2 2) " mm")) (princ "\n=========================================") ;; --- Winkelabfrage --- (setq winkel (getreal "\n\nGefaellewinkel (°) [3]: ")) (if (or (null winkel) (<= winkel 0)) (setq winkel (ssg-cfg-or "gefaelle" "default_winkel" 3.0))) (setq winkel (float winkel)) (setq rad (* winkel (/ pi 180.0))) (princ (strcat "\n>>> Gewaehlter Winkel: " (rtos winkel 2 1) grad-zeichen)) ;; --- Seite abfragen --- (princ "\n\nEin-/Auselement - Seite waehlen:") (princ "\n 1 - Links (_3D_AS_90_links / _3D_ES_90_links)") (princ "\n 2 - Rechts (_3D_AS_90_rechts / _3D_ES_90_rechts)") (setq antwort (getstring "\nIhre Wahl (1/2) [1]: ")) (if (= antwort "2") (setq seite "rechts") (setq seite "links") ) (princ (strcat "\n>>> Seite: " seite)) ;; --- Laengenberechnung --- ;; Horizontalbilanz: deltaL = aus_dx + L_stau*cos(rad) + 300*cos(rad) + ein_dx ;; L_stau (Weglaenge) = (deltaL - aus_dx - ein_dx - 300*cos(rad)) / cos(rad) (setq sep-x (* (ssg-cfg-or "gefaelle" "separator_breite" 300.0) (cos rad))) (setq L_stau (/ (- deltaL aus-dx ein-dx sep-x) (cos rad))) ;; --- Validierung --- (if (<= L_stau 0.1) (progn (alert (strcat "Berechnete Staustreckenlaenge ungueltig: " (rtos L_stau 2 2) " mm\n" "Bitte groessere ΔL oder kleineren Winkel waehlen.")) (exit) ) ) ;; --- Ausgabe Zusammenfassung --- (princ "\n\n=========================================") (princ (strcat "\n>>> Gewaehlter Winkel: " (rtos winkel 2 1) grad-zeichen)) (princ (strcat "\n>>> Seite: " seite)) (princ (strcat "\n>>> L_stau (Weglaenge): " (rtos L_stau 2 2) " mm")) (princ (strcat "\n>>> Separator Horiz.: " (rtos sep-x 2 2) " mm")) (princ "\n=========================================") ;; --- Bestaetigungsdialog --- (princ "\n\nGefaellestrecke einfuegen?") (princ "\n 1 - Ja, einfuegen") (princ "\n 2 - Nein, abbrechen") (setq antwort (getstring "\nIhre Wahl (1/2) [1]: ")) (if (not (= antwort "2")) (gefaellestrecke-einfuegen L_stau (fix winkel) startpunkt-fuer-einfuegen seite) (princ "\nVorgang abgebrochen.") ) nil ) ;; ============================================================ ;; START ;; ============================================================ (princ "\n=========================================") (princ "\n>>> GEFAELLESTRECKE v1.0 geladen <<<") (princ "\n>>> Befehl: GEFAELLESTRECKE <<<")