;------------------------------------------------------------------------;
; Bügelplätze zeichnen  - TYP 2 -                                        ;
; -----------------------------------------------------------------------;
; -----------------------------------------------------------------------;
; 22.3.93 / 12.06.1998                                                ;
;------------------------------------------------------------------------;
(defun Dbox (/ Dat)
  (setq Dat (load_dialog (strcat lw "/acadsst/module/b_typ2.dcl")))
  (if (not (new_dialog "b_typ2" Dat)) (exit))
  (set_tile "L1"      m_L1)
  (set_tile "L2"      m_L2)
  (set_tile "L3"      m_L3)
  (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(btyp02_1)")
  )
  (if (= m_ART "ART_2")  ; Nr 2
    (slide_image 0 0 breite hoehe "arbplz(btyp02_2)")
  )
  (if (= m_ART "ART_3")  ; Nr 3
    (slide_image 0 0 breite hoehe "arbplz(btyp02_3)")
  )
  (end_image)
)

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

(defun SetPara ()
  (setq m_L1       (get_tile "L1")     ; Breite
	  m_L3       (get_tile "L3")     ; Tiefe
	  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 L3     (atoi m_L3))               ; Tiefe
  (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 "\nUntere linke Ecke definieren: "))
  (initget (+ 2 4))
  ;-------------------Prüfung ob die Grenzwerte eingehalten ---
  (while (or (< L1 1600) (> L1 5000))      
  (initget (+ 1 2 4))
  (setq L1 (getreal "\nBreite eingeben [1600-5000]: "))
  )
  (while (or (< L3 1600) (> L3 10000))      
  (initget (+ 1 2 4))
  (setq L1 (getreal "\nTiefe eingeben [1600-10000]: "))
  )
  (while (or (< L2 700) (> L2 2000))      
  (initget (+ 1 2 4))
  (setq L2 (getint "\nBreite eingeben [700-2000]: "))
  )
)

(defun punkte()
  ;--------------------------------------------------------
  ;<<<<<  Konstruktionspunkte definieren >>>>>>>
  ;--------------------------------------------------------
  (setq P1 (list (+ (car p0) L1 400) (+ (cadr p0) L2)))
  (setq P2 (list (car p0) (+ (cadr p0) L2)))
  (setq P3 (list (car p0) (+ (cadr p0) L2 L3)))
  (setq P4 (list (+ (car p0) L1) (cadr p3)))
  (setq P5 (list (car p4) (cadr p2)))
  (setq P6 (list (car p5) (+ (cadr p5) 400)))
  (setq P7 (list (car p0) (cadr p6)))
  (setq P8 (list (- (car p1) L2) (cadr p0)))
  (setq P9 (list (+ (car p1) L2) (cadr p0)))
  (setq P10 (list (car p3) (- (cadr p3) 800)))
  (setq P11 (list (car p2) (+ (cadr p2) 670)))
  (setq P12 (list (car p4) (- (cadr p4) 800)))
  (setq P13 (list (car p5) (+ (cadr p5) 670)))
  (setq P14 (list (+ (car p3) 800) (cadr p3)))
  (setq P15 (list (- (car p4) 800) (cadr p4)))
  (setq P16 (list (- (car p1) 283) (- (cadr p1) 283)))
  (setq P17 (list (+ (car p8) 400) (+ (cadr p8) 400)))
  (setq P18 (list (+ (car p1) 283) (- (cadr p1) 283)))
  (setq P19 (list (- (car p9) 400) (+ (cadr p9) 400)))
  (setq P20 (list (+ (car p8) 375) (cadr p8)))
  (setq P21 (list (- (car p9) 375) (cadr p9)))
  (setq P22 (list (- (car p8) 425) (cadr p8)))
  (setq P23 (list (+ (- (car p0) 400) L2 425) (cadr p0)))
  (setq P24 (list (- (car p3) 400) (+ (cadr p3) 400)))
  (setq P25 (list (+ (car p9) 400) (- (cadr p9) 400)))
  (cond
    ((= ART 1)
    (setq P26 (list (+ (car p11) (/ L1 2)) (cadr p11)))
    (setq P27 (list (- (car p26) 700) (+ (cadr p26) 450)))
    (setq P28 (list (- (car p26) 1000) (- (cadr p26) 400)))
    (setq P29 (list (+ (car p26) 500) (+ (cadr p26) 200))) 
    )
    ((= ART 2)
    (setq P26 (list (+ (car p11) (/ L1 2)) (- (cadr p10) 200)))
    (setq P27 (list (- (car p12) 450) (+ (cadr p13) 500)))
    (setq P28 (list (- (car p26) 750) (- (cadr p26) 350)))
    (setq P29 (list (+ (car p26) 1100) (+ (cadr p26) 100))) 
    )
    ((= ART 3)
    (setq P26 (list (+ (car p11) (/ L1 2)) (cadr p10)))
    (setq P27 (list (- (car p13) 300) (cadr p13)))
    (setq P28 (list (- (car p26) 1200) (- (cadr p26) 200)))
    (setq P29 (list (- (car p5) 500) (+ (cadr p5) 700))) 
    )
  )
)

(defun geometrie()
  ;----------------------------------------------------------
  ;<<<<<<   Blöcke einfgen  >>>>>>
  ;----------------------------------------------------------
  (command "_layer" "_m" "L-2" "_c" "2" "" "")
  (command "_insert" (strcat lw "/acadsst/layout/kw800_8x") P1 "" "" "0")
  (setq auswahl-satz (ssget "_L"))
  (command "_insert" (strcat lw "/acadsst/layout/s90650l8") P3 "" "" "180")
  (ssadd (entlast) auswahl-satz)
  (command "_insert" (strcat lw "/acadsst/layout/s90650l8") P4 "" "" "90")
  (ssadd (entlast) auswahl-satz)
  (command "_insert" (strcat lw "/acadsst/layout/s45400r4") P7 "" "" "270")
  (ssadd (entlast) auswahl-satz)
  (command "_insert" (strcat lw "/acadsst/layout/s45400l4") P6 "" "" "270")
  (ssadd (entlast) auswahl-satz)
  (command "_insert" (strcat lw "/acadsst/layout/w45650l4") P8 "" "" "0")
  (ssadd (entlast) auswahl-satz)
  (command "_insert" (strcat lw "/acadsst/layout/w45650r4") P9 "" "" "180")
  (ssadd (entlast) auswahl-satz)
  (command "_line" p2 p5 "")
  (ssadd (entlast) auswahl-satz)
  (command "_line" p10 p11 "")
  (ssadd (entlast) auswahl-satz)
  (command "_line" p12 p13 "")
  (ssadd (entlast) auswahl-satz)
  (command "_line" p14 p15 "")
  (ssadd (entlast) auswahl-satz)
  (command "_line" p16 p17 "")
  (ssadd (entlast) auswahl-satz)
  (command "_line" p18 p19 "")
  (ssadd (entlast) auswahl-satz)
  (command "_line" p20 p21 "")
  (ssadd (entlast) auswahl-satz)
  (command "_line" p22 p23 "")
  (ssadd (entlast) auswahl-satz)

  ;----------------- Pfeile setzen ---------------------------------------
  (command "_layer" "_m" "Z-1" "_c" "1" "" "")
  (cond
    ((= ART 1)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_l") p10 "" "" "270")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_v") p13 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_v") p19 "" "" "135")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_l") p16 "" "" "225")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/maus") p26 "" "" "0")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/vario14") p27 "" "" "270")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegelr") p22 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegelr") p12 "" "" "0")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegelr") p11 "" "" "180")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pfeil") p28 "" "" "45")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pfeil") p29 "" "" "315")
      (ssadd (entlast) auswahl-satz)
    )
    ((= ART 2)   
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_v") p10 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_l") p13 "" "" "270")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_l") p19 "" "" "315")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_v") p17 "" "" "45")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/maus") p26 "" "" "180")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/vario14") p27 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegel") p22 "" "" "270")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegel") p12 "" "" "180")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegel") p11 "" "" "0")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pfeil") p28 "" "" "225")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pfeil") p29 "" "" "180")
      (ssadd (entlast) auswahl-satz)
    )
    ((= ART 3)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_l") p10 "" "" "270")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_v") p13 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_v") p19 "" "" "135")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pf0_l") p5 "" "" "180")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/maus") p26 "" "" "180")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/dobli-fw") p27 "" "" "180")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegelr") p22 "" "" "90")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegelr") p12 "" "" "0")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/buegelr") p11 "" "" "180")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pfeil") p28 "" "" "0")
      (ssadd (entlast) auswahl-satz)
      (command "_insert" (strcat lw "/acadsst/zier2d/pfeil") p29 "" "" "315")
      (ssadd (entlast) auswahl-satz)
    )
  )

  (IF (> K0 1)
	(command "_array" auswahl-satz "" "_r" "1" m_K0 (itoa (+ L1 800)))
  )
) 

;-----------------------------------------------------------------
(defun c:b_typ2 (/ L1 L2 L3 K0 ART P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 
P12 P13 P14 P15 P16 P17 P18 P19 P20 P21 P22 P23 P24 P25 P26 P27 P28 P29)
  (setvar "limcheck" 0)
  (prompt "**** Bügelplatz TYP 2 *******")
  (if (null m_L1)    (setq m_L1       "4600"   ))     ; Breite
  (if (null m_L3)    (setq m_L3       "2400"   ))     ; Tiefe
  (if (null m_K0)    (setq m_K0       "1"      ))     ; Anzahl der Plätze
  (if (null m_ART)   (setq m_ART      "ART_1"  ))     ; Art
  (if (null m_L2)    (setq m_L2       "800"    ))     ; Streckenabstand
  (setq auswahl-satz nil)
  (Dbox)
  (prompt "")
  (datain)
  (punkte)
  (geometrie)
)
;------------------------------------------------------------------