;------------------------------------------------------------------------;
; ILS 2100 ANGEBOT                                                       ;
;------------------------------------------------------------------------;
; AW 18.11.2007                                                          ;
;    23.01.2009 Bereinigung und Ergänzung                                              ;
;------------------------------------------------------------------------;
(defun Dbox (/ Dat)
  (setq Dat (load_dialog (strcat lw "/acadsst/ils2100/ILS_ANGEBOT.DCL")))
  (if (not (new_dialog "ILS_ANGEBOT" Dat)) (exit))
  (set_tile "DWG_NAME" m_DWG_NAME); Blockname
  (set_tile "RICHT"     m_RICHT)  
  (mode_tile "anzeige" 0)
  (SetDia)
  
  (ACTION_TILE "DWG_NAME" "(zeig_dia)")
  (ACTION_TILE "RICHT" "(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_DWG_NAME "0") ; Antrieb 800
		(slide_image 0 0 breite hoehe "ils2100(B3000010)")
  )
  (if (= m_DWG_NAME "1") ; Spannstation 800
    (slide_image 0 0 breite hoehe "ils2100(B3000030)")
  )
  (if (= m_DWG_NAME "2") ; Umlenkstation 800
    (slide_image 0 0 breite hoehe "ils2100(B3000050)")
  )
  (if (= m_DWG_NAME "3") ; Antrieb 300
		(slide_image 0 0 breite hoehe "ils2100(B3000020)")
  )
  (if (= m_DWG_NAME "4") ; Spannstation 300
		(slide_image 0 0 breite hoehe "ils2100(B3000040)")
  )
  (if (= m_DWG_NAME "5") ; AS
		(progn
		  (if (= m_RICHT "LINKS")
				(slide_image 0 0 breite hoehe "ils2100(B300020L)")
				(slide_image 0 0 breite hoehe "ils2100(B300020R)")
			)
    )
  )
  (if (= m_DWG_NAME "6") ; ES
		(progn
		  (if (= m_RICHT "LINKS")
				(slide_image 0 0 breite hoehe "ils2100(B300021L)")
				(slide_image 0 0 breite hoehe "ils2100(B300021R)")
			)
    )
  )
  (if (= m_DWG_NAME "7") ; Separator
		(slide_image 0 0 breite hoehe "ils2100(B3000150)")
  )
  (if (= m_DWG_NAME "8") ; Gefälle
    (slide_image 0 0 breite hoehe "ils2100(B3000160)")
  )
  (if (= m_DWG_NAME "9") ; Scanner für BM
    (slide_image 0 0 breite hoehe "ils2100(B3000170)")
  )
  (if (= m_DWG_NAME "10") ; Scanner manuell für Bekleidung
    (slide_image 0 0 breite hoehe "ils2100(B3000171)")
  )
  (if (= m_DWG_NAME "11") ; Scanner automatisch
    (slide_image 0 0 breite hoehe "ils2100(B3000175)")
  )
  (if (= m_DWG_NAME "12") ; Beladung
    (slide_image 0 0 breite hoehe "ils2100(B3000320)")
  )
  (if (= m_DWG_NAME "13") ; Entladung
    (slide_image 0 0 breite hoehe "ils2100(B3000310)")
  )
  (if (= m_DWG_NAME "14") ; AE 30 GRAD rechts/links
		(progn
		  (if (= m_RICHT "LINKS")
				(slide_image 0 0 breite hoehe "ils2100(B3000340)")
				(slide_image 0 0 breite hoehe "ils2100(B3000345)")
			)
    )
  )
  (if (= m_DWG_NAME "15") ; ETF Umlenkung rechts/links
		(progn
		  (if (= m_RICHT "LINKS")
				(slide_image 0 0 breite hoehe "ils2100(B3000360)")
				(slide_image 0 0 breite hoehe "ils2100(B3000365)")
			)
    )
  )
  (if (= m_DWG_NAME "16") ; ETF Antrieb rechts/links
		(progn
		  (if (= m_RICHT "LINKS")
				(slide_image 0 0 breite hoehe "ils2100(B3000350)")
				(slide_image 0 0 breite hoehe "ils2100(B3000355)")
			)
    )
  )
  (if (= m_DWG_NAME "17") ; EE 30 GRAD rechts/links
		(progn
		  (if (= m_RICHT "LINKS")
				(slide_image 0 0 breite hoehe "ils2100(B3000330)")
				(slide_image 0 0 breite hoehe "ils2100(B3000335)")
			)
    )
  )
  (if (= m_DWG_NAME "18") ; ETF kompl. rechts/links
		(progn
		  (if (= m_RICHT "LINKS")
				(slide_image 0 0 breite hoehe "ils2100(ETF_L)")
				(slide_image 0 0 breite hoehe "ils2100(ETF_R)")
			)
    )
  )

  (end_image)
)

(defun zeig_dia()
  (setq m_DWG_NAME (get_tile "DWG_NAME"))
  (setq m_RICHT (get_tile "RICHT"))

  (if (= m_DWG_NAME "0") ; Antrieb 800
    (mode_tile "RICHT" 1)  
  )
  (if (= m_DWG_NAME "1") ; Spannstation 800
    (mode_tile "RICHT" 1)  
  )
  (if (= m_DWG_NAME "2") ; Umlenkstation 800
    (mode_tile "RICHT" 1)  
  )
  (if (= m_DWG_NAME "3") ; Antrieb 300
    (mode_tile "RICHT" 1) 
  )
  (if (= m_DWG_NAME "4") ; Spannstation 300
    (mode_tile "RICHT" 1)  
  )
  (if (= m_DWG_NAME "5") ; AS
    (mode_tile "RICHT" 0)  
  )
  (if (= m_DWG_NAME "6") ; ES
    (mode_tile "RICHT" 0)  
  )
  (if (= m_DWG_NAME "7") ; Separator
    (mode_tile "RICHT" 1)  
  )
  (if (= m_DWG_NAME "8") ; Gefälle
    (mode_tile "RICHT" 1)  
  )
  (if (= m_DWG_NAME "9") ; Scanner für BM
    (mode_tile "RICHT" 1)  
  )
  (if (= m_DWG_NAME "10") ; Scanner manuell für Bekleidung
    (mode_tile "RICHT" 1)  
  )
  (if (= m_DWG_NAME "11") ; Scanner automatisch
    (mode_tile "RICHT" 1)  
  )
  (if (= m_DWG_NAME "12") ; Beladung
    (mode_tile "RICHT" 1)  
  )
  (if (= m_DWG_NAME "13") ; Entladung
    (mode_tile "RICHT" 1)  
  )
  (if (= m_DWG_NAME "14") ; AE 30 GRAD rechts/links
    (mode_tile "RICHT" 0)  
  )
  (if (= m_DWG_NAME "15") ; ETF Umlenkung rechts/links
    (mode_tile "RICHT" 0)  
  )
  (if (= m_DWG_NAME "16") ; ETF Antrieb rechts/links
    (mode_tile "RICHT" 0)  
  )
  (if (= m_DWG_NAME "17") ; EE 30 GRAD rechts/links
    (mode_tile "RICHT" 0)  
  )
  (if (= m_DWG_NAME "18") ; ETF kompl. rechts/links
    (mode_tile "RICHT" 0)  
  )
  
  (SetDia)
)

(defun setpara()
  (setq m_DWG_NAME (get_tile "DWG_NAME"))
  (setq m_RICHT    (get_tile "RICHT"))  
)

(defun datain ()  
  (setq dummy nil)
)

(defun geometrie()
	(setq NEV "")
	(setq E_ARTINR "")
	(setq E_BEZEICHNUNG "")

  (if (= m_DWG_NAME "0") ; Antrieb 800 
    (progn
		  (command "_layer" "_m" "ILS-ANTRIEB" "_c" "1" "" "")
      (setq BL_NAME "0_B3000010")
    )  
  )
  (if (= m_DWG_NAME "1") ; Spannstation 800 
    (progn
		  (command "_layer" "_m" "ILS-SPANNSTATION" "_c" "2" "" "")
      (setq BL_NAME "0_B3000030")
    )  
  )
  (if (= m_DWG_NAME "2") ; Umlenkstation 800 
    (progn
		  (command "_layer" "_m" "ILS-UMLENKSTATION" "_c" "2" "" "")
      (setq BL_NAME "0_B3000050")
    )  
  )
  (if (= m_DWG_NAME "3") ; Antrieb 300 
    (progn
		  (command "_layer" "_m" "ILS-ANTRIEB" "_c" "1" "" "")
      (setq BL_NAME "0_B3000020")
    )  
  )
  (if (= m_DWG_NAME "4") ; Spannstation 300 
    (progn
		  (command "_layer" "_m" "ILS-SPANNSTATION" "_c" "2" "" "")
      (setq BL_NAME "0_B3000040")
    )  
  )
  (if (= m_DWG_NAME "5") ; AS
    (progn
		  (command "_layer" "_m" "ILS-AS" "_c" "1" "" "")
		  (if (= m_RICHT "LINKS")
	      (setq BL_NAME "0_B3000200_L")
	      (setq BL_NAME "0_B3000200_R")
			)
    )  
  )
  (if (= m_DWG_NAME "6") ; ES
    (progn
		  (command "_layer" "_m" "ILS-ES" "_c" "7" "" "")
		  (if (= m_RICHT "LINKS")
	      (setq BL_NAME "0_B3000210_L")
	      (setq BL_NAME "0_B3000210_R")
			)
    )  
  )
  (if (= m_DWG_NAME "7") ; Separator
    (progn
		  (command "_layer" "_m" "ILS-SP" "_c" "3" "" "")
      (setq BL_NAME "0_B3000150")
    )  
  )
  (if (= m_DWG_NAME "8") ; Separator Gefälle 
  	(progn
		  (command "_layer" "_m" "ILS-SP-G" "_c" "4" "" "")
			(setq BL_NAME "0_B3000160")
		)
  )
  (if (= m_DWG_NAME "9") ; Scanner für Betriebsmittel 
  	(progn
		  (command "_layer" "_m" "ILS-SCANNER" "_c" "5" "" "")
			(setq BL_NAME "0_B3000170")
		)
  )
  (if (= m_DWG_NAME "10") ; Handscanner 
  	(progn
		  (command "_layer" "_m" "ILS-SCANNER" "_c" "5" "" "")
			(setq BL_NAME "0_B3000171")
		)
  )
  (if (= m_DWG_NAME "11") ; Automatik Scanner für die Ware 
  	(progn
		  (command "_layer" "_m" "ILS-SCANNER" "_c" "5" "" "")
			(setq BL_NAME "0_B3000175")
		)
  )
  (if (= m_DWG_NAME "12") ; Beladung
  	(progn
		  (command "_layer" "_m" "ILS-BELADUNG" "_c" "3" "" "")
			(setq BL_NAME "0_B3000320")
		)
  )
  (if (= m_DWG_NAME "13") ; Entladung
  	(progn
		  (command "_layer" "_m" "ILS-ENTLADUNG" "_c" "4" "" "")
			(setq BL_NAME "0_B3000310")
		)
  )
  (if (= m_DWG_NAME "14") ; AE 30 GRAD rechts/links
		(progn
		  (command "_layer" "_m" "ILS-ETF" "_c" "6" "" "")
		  (if (= m_RICHT "LINKS")
	      (setq BL_NAME "0_B3000340")
	      (setq BL_NAME "0_B3000345")
			)
    )
  )
  (if (= m_DWG_NAME "15") ; ETF Umlenkung rechts/links
		(progn
		  (command "_layer" "_m" "ILS-ETF" "_c" "6" "" "")
		  (if (= m_RICHT "LINKS")
	      (setq BL_NAME "0_B3000360")
	      (setq BL_NAME "0_B3000365")
			)
    )
  )
  (if (= m_DWG_NAME "16") ; ETF Antrieb rechts/links
		(progn
		  (command "_layer" "_m" "ILS-ETF" "_c" "6" "" "")
		  (if (= m_RICHT "LINKS")
	      (setq BL_NAME "0_B3000350")
	      (setq BL_NAME "0_B3000355")
			)
    )
  )
  (if (= m_DWG_NAME "17") ; EE 30 GRAD rechts/links
		(progn
		  (command "_layer" "_m" "ILS-ETF" "_c" "6" "" "")
		  (if (= m_RICHT "LINKS")
	      (setq BL_NAME "0_B3000330")
	      (setq BL_NAME "0_B3000335")
			)
    )
  )
  (if (= m_DWG_NAME "18") ; ETF kompl. rechts/links
		(progn
		  (command "_layer" "_m" "ILS-ETF" "_c" "6" "" "")
		  (if (= m_RICHT "LINKS")
	      (setq BL_NAME "ETF_L")
	      (setq BL_NAME "ETF_R")
			)
    )
  )


  (setq P0  (getpoint "\nPick insert point: "))
;  (bl-name P0) ;--> Block-Name definieren -> Rckgabe: element-name  
  (setq BL_NAME (strcat lw "/acadsst/ils2100/" BL_NAME))
  (command "_insert" BL_NAME P0 "" "" pause)
;	(attribute-aendern "" "" "" "" "" block-kennung "" "" "" "")  

;----------------------------------------------------------------------  
;  (if (or (= m_DWG_NAME "0") (= m_DWG_NAME "1"))  ; AS-Element
;    (progn
;      (setq AUSWAHL-SATZ (ssget "_L"))
;      (EINZELTEIL E_ARTINR E_BEZEICHNUNG "1")
;      (mach-block P0 "0" AUSWAHL-SATZ)
;      (attribute-aendern "0" "2" "3" "0" "0" block-kennung "333333333" (strcat NEV "MIT " E_BEZEICHNUNG) "1" "")
;    )
;  )
;----------------------------------------------------------------------
)

;(defun EINZELTEIL (E_ARTINR E_BEZEICHNUNG E_MENGE)
;  (command "_layer" "_m" "ILS-COMPONENTS" "_c" "7" "" "")  
;  (command "_insert" (strcat lw "/acadsst/ils2100/d_einzel") P0 "" "" "0") 
;  (attribute-aendern "0" "0" "23" "" "" block-kennung E_ARTINR E_BEZEICHNUNG E_MENGE "")     
;  (ssadd (entlast) AUSWAHL-SATZ)
;)

;------------------------------------------------------------------------------
(defun c:ILS_ANGEBOT ( / DWG_NAME BL_NAME P0) 
  (setvar "limcheck" 0)
  (setvar "CMDECHO" 0)
  (setvar "BLIPMODE" 0)
  (setq ALTFANG (getvar "osmode"))  
  (setq EINZEL 0) ; fuer EINZEL=0 Baugruppen / EINZEL=1 fuer APB
  (prompt "**** ILS ANGEBOT MOULE *******")
  (prompt "")
  (if (null m_DWG_NAME)(setq m_DWG_NAME "0"))        ; Anfangssymbolname 
  (if (null m_RICHT)    (setq m_RICHT "LINKS"))      ; Richtung  
  (Dbox)
  (prompt "")
  (datain)
  (geometrie)
	(setvar "osmode" ALTFANG)  
)
