;------------------------------------------------------------------------;
; Bügelplätze zeichnen  - TYP 3 -                                        ;
; -----------------------------------------------------------------------;
; -----------------------------------------------------------------------;
; 27.09.93 / 12.6.98                                                            ;
;------------------------------------------------------------------------;
(defun Dbox (/ Dat)
  (setq Dat (load_dialog (strcat lw "/acadsst/module/b_typ3.dcl")))
  (if (not (new_dialog "b_typ3" Dat)) (exit))
  (set_tile "L1"      m_L1)
  (set_tile "L2"      m_L2)
  (set_tile "K0"      m_K0)
  (set_tile "ART"     m_ART)
  (SetDia)
  (ACTION_TILE "ART"  "(zeig_dia)")
  (action_tile "accept" "(SetPara) (done_dialog)")
  (action_tile "cancel" "(exit) (done_dialog)")
  (start_dialog)
  (unload_dialog Dat)
)

(defun SetDia()
  (setq breite (dimx_tile "anzeige"))
  (setq hoehe  (dimy_tile "anzeige"))
  (start_image "anzeige")
  (FILL_IMAGE 0 0 breite hoehe -18)
  (if (= m_ART "ART_1")  ; Nr 1
    (slide_image 0 0 breite hoehe "arbplz(btyp03_1)")
  )
  (if (= m_ART "ART_2")  ; Nr 2
    (slide_image 0 0 breite hoehe "arbplz(btyp03_2)")
  )
  (if (= m_ART "ART_3")  ; Nr 3
    (slide_image 0 0 breite hoehe "arbplz(btyp03_3)")
  )
  (end_image)
)

(defun zeig_dia()
  (setq m_ART (get_tile "ART"))
  (SetDia)
)

(defun SetPara ()
  (setq m_L1       (get_tile "L1")     ; Breite
	  m_K0       (get_tile "K0")     ; Anzahl Plätze
	  m_ART      (get_tile "ART")    ; Art
	  m_L2       (get_tile "L2")     ; Streckenabstand
  )
)

(defun datain()  
  (setq L1     (atoi m_L1))               ; Breite
  (setq K0     (atoi m_K0))               ; Anzahl Plätze
  (setq ART    (atoi (substr m_ART 5 1))) ; Art
  (setq L2     (atoi m_L2))               ; Streckenabstand  
  ;----------------------------------------------------------------------;
  ; >>>>>> Eingabeteil <<<<<<                                            ;
  ;----------------------------------------------------------------------;
  (setq P0 (getpoint "\nObere linke Ecke definieren: "))
  (initget (+ 2 4))
  ;----------------------------------------------------------------------;
  ; >>>>>> PrÜfung ob die Grenzwerte eingehalten sind <<<<<<             ;
  ;----------------------------------------------------------------------;
  (while (or (< L1 2000) (> L1 6000))      
  (initget (+ 1 2 4))
  (setq L1 (getreal "\nBreite eingeben [2000-6000]: "))
  )

  (while (or (< L2 800) (> L2 2000))      
  (initget (+ 1 2 4))
  (setq L2 (getint "\nStreckenabstand eingeben [800-2000]: "))
  )
)

(defun punkte()
  ;-----------------------------------------------------------------------;
  ; >>>>>> Konstruktionspunkte definieren <<<<<<                          ;
  ;-----------------------------------------------------------------------;
  (setq P1 (list (car p0)                (- (cadr p0) 800)))
  (setq P2 (list (car p0)                (- (cadr p1) L2)))
  (setq P3 (list (car p0)                (+ (cadr p2) 800)))
  (setq P4 (list (car p0)                (- (cadr p3) L2)))
  (setq P5 (list (+ (car p1) 800)        (cadr p1)))
  (setq P6 (list (+ (car p2) 800)        (cadr p2)))
  (setq P7 (list (+ (car p1) L1)         (cadr p1)))
  (setq P8 (list (+ (car p2) L1)         (cadr p2)))
  (setq P9 (list (- (car p4) 300)        (- (cadr p4) 300)))
  (setq P10 (list (+ (car p7) 2500)      (+ (cadr p7) 1000)))
  (cond
    ((= ART 1)
    (setq P11 (list (- (car p8) 400)     (cadr p8)))
    (setq P12 (list (- (car p7) 400)     (cadr p7)))
    (setq P13 (list (+ (car p1) 1175)    (cadr p1)))
    (setq P14 (list (+ (car p2) 800)    (cadr p2))) 
    (setq P15 (list (car p1)             (+ (cadr p1) 400)))
    (setq P16 (list (car p2)             (+ (cadr p2) 700)))
    (setq P17 (list (+ (car p8) 1800)    (+ (cadr p8) 250)))
    (setq P18 (list (- (car p17) 700)    (+ (cadr p17) 560))) 
    (setq P19 (list (+ (car p7) 150)     (- (cadr p7) 200)))
    (setq P20 (list (+ (car p8) 300)     (+ (cadr p8) 300))) 
    )
    ((= ART 2)
    (setq P11 (list (- (car p8) 400)     (cadr p8)))
    (setq P12 (list (- (car p7) 400)     (cadr p7)))
    (setq P13 (list (+ (car p1) 800)     (cadr p1)))
    (setq P14 (list (+ (car p2) 1175)    (cadr p2))) 
    (setq P15 (list (car p1)             (+ (cadr p1) 700)))
    (setq P16 (list (car p2)             (+ (cadr p2) 400)))
    (setq P17 (list (+ (car p8) 1800)    (+ (cadr p8) 250)))
    (setq P18 (list (- (car p17) 700)    (+ (cadr p17) 560))) 
    (setq P19 (list (+ (car p7) 300)     (- (cadr p7) 300)))
    (setq P20 (list (+ (car p8) 150)     (+ (cadr p8) 200))) 
    )
    ((= ART 3)
    (setq P11 (list (- (car p8) 400)     (cadr p8)))
    (setq P12 (list (- (car p7) 400)     (cadr p7)))
    (setq P13 (list (+ (car p1) 1175)    (cadr p1)))
    (setq P14 (list (+ (car p2) 800)     (cadr p2))) 
    (setq P15 (list (car p1)             (+ (cadr p1) 400)))
    (setq P16 (list (car p2)             (+ (cadr p2) 700)))
    (setq P17 (list (+ (car p7) 200)     (+ (cadr p7) 100)))
    (setq P18 (list (+ (car p17) 1000)   (- (cadr p17) 1100))) 
    (setq P19 (list (+ (car p7) 150)     (- (cadr p7) 200)))
    (setq P20 (list (+ (car p8) 300)     (+ (cadr p8) 300))) 
    )
  )
)

(defun geometrie()
  ;-----------------------------------------------------------------------;
  ; >>>>>> Bl”cke einfgen  <<<<<<                                        ;
  ;-----------------------------------------------------------------------;
  (command "_layer" "_m" "L-2" "_c" "2" "" "")
  (command "_insert" (strcat lw "/acadsst/layout/w90650l8") P1 "" "" "-90")
  (setq auswahl-satz (ssget "_L"))
  (command "_insert" (strcat lw "/acadsst/layout/w90650l8") P2 "" "" "-90")
  (ssadd (entlast) auswahl-satz)
  (command "_insert" (strcat lw "/acadsst/layout/endp") P7 "" "" "")
  (ssadd (entlast) auswahl-satz)
  (command "_insert" (strcat lw "/acadsst/layout/endp") P8 "" "" "")
  (ssadd (entlast) auswahl-satz)
  (command "_line" p1 p3 "")
  (ssadd (entlast) auswahl-satz)
  (command "_line" p5 p7 "")
  (ssadd (entlast) auswahl-satz)
  (command "_line" p6 p8 "")
  (ssadd (entlast) auswahl-satz)
  (command "_line" p2 p4 "")
  (ssadd (entlast) auswahl-satz)
  ;-----------------------------------------------------------------------;
  ; >>>>>> Pfeile + Maschinen setzen <<<<<<                               ;
  ;-----------------------------------------------------------------------;
  (command "_layer" "_m" "Z-1" "_c" "1" "" "")
  (cond
    ((= ART 1)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_l") p13 "" "" "180")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_v") p14 "" "" "")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_l") p15 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_v") p16 "" "" "-90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/maus") p18 "" "" "180")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/vario14") p17 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegelr") p11 "" "" "-90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegelr") p12 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pfeil") p19 "0.5" "0.5" "-45")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pfeil") p20 "0.5" "0.5" "225")
      (ssadd (entlast) auswahl-satz)
    )
    ((= ART 2)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_v") p13 "" "" "")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_l") p14 "" "" "180")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_v") p15 "" "" "-90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_l") p16 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/maus") p18 "" "" "180")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/vario14") p17 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegel") p11 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegel") p12 "" "" "-90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pfeil") p19 "0.5" "0.5" "135")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pfeil") p20 "0.5" "0.5" "45")
      (ssadd (entlast) auswahl-satz)
    )
    ((= ART 3)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_l") p13 "" "" "180")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_v") p14 "" "" "")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_l") p15 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_v") p16 "" "" "-90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/maus") p18 "" "" "")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/dobli-fw") p17 "" "" "")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegelr") p11 "" "" "-90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegelr") p12 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pfeil") p19 "0.5" "0.5" "-45")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pfeil") p20 "0.5" "0.5" "225")
      (ssadd (entlast) auswahl-satz)
    )
  )
  (If (> K0 1)
      (command "_array" auswahl-satz "" "_r" m_K0 "1" (itoa (* 2 L2)))
  )
) 

;-------------------------------------------------------------------------;
; >>>>>> Programm <<<<<<                                                  ;
;-------------------------------------------------------------------------;
(defun c:b_typ3 (/ L1 L2 L3 KO ART P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12
P13 P14 P15 P16 P17 P18 P19 P20) 
  (setvar "limcheck" 0)
  (prompt "**** Bügelplatz TYP 3 *******")
  (if (null m_L1)    (setq m_L1       "2000"   ))     ; Breite
  (if (null m_L2)    (setq m_L2       "800"    ))     ; Streckenabstand
  (if (null m_K0)    (setq m_K0       "1"      ))     ; Anzahl der Plätze
  (if (null m_ART)   (setq m_ART      "ART_1"  ))     ; Art
  (setq auswahl-satz nil)
  (Dbox)
  (prompt "")
  (datain)
  (punkte)
  (geometrie)
)
;-------------------------------------------------------------------------;
; >>>>>> Ende <<<<<<                                                      ;
;-------------------------------------------------------------------------;