;------------------------------------------------------------------------;
; ELEKTRO  - Layout                                                      ;
; -----------------------------------------------------------------------;
; AW 1.9.94 / 18.05.97                                                   ;
;------------------------------------------------------------------------;

(defun Dbox (/ Dat)
  (setq Dat (load_dialog (strcat lw "/acadsst/steuerg/elektro.DCL")))
  (if (not (new_dialog "elektro" Dat)) 
    (exit)
  )
  (set_tile "NULLTR"     m_NULLTR)  ; Null Trolley
  (set_tile "KOMP"       m_KOMP)    ; Art der Komponente
  (SetVisibility)
  (set_tile "SCAN"       m_SCAN)    ; Scannerart
  (set_tile "NORM"       m_NORM)    ; Deutsch oder US Norm
  (set_tile "REVERS"     m_REVERS)  ; Antrieb reversibel oder nicht
  (set_tile "ZUSATZ"     m_ZUSATZ)  ; Deutsch oder US Norm
  (set_tile "W1"         m_W1)      ; Beschriftung 1. Weiche
  (set_tile "W2"         m_W2)      ; Beschriftung 2. Weiche
  (set_tile "LAGE1"      m_LAGE1)   ; Weiche - VON / NACH
  (set_tile "ZB"         m_ZB)      ; Anzahl Sensoren
  (set_tile "ZY"         m_ZY)      ; Anzahl Magnetventile
  (set_tile "ZM"         m_ZM)      ; Anzahl Motoren
  (set_tile "VAR_F"      m_VAR_F)   
  (set_tile "EBEN"       m_EBEN)    ; Layer
  (set_tile "A_EBENE"    m_EBENE)   ; Anlagenebene 
  (set_tile "A_ORT"      m_ORT)     ; 10-11 / 10.01
  (set_tile "A_KLKAST"   m_KLKAST)  ; Klemmkasten
  (set_tile "A_IBS-UV"   m_IBS-UV)  ; Interbuskasten
  (set_tile "A_KOMMENT"  m_KOMMENT) ; Kommentar

  (ACTION_TILE "KOMP" "(zeig_dia)")
  (action_tile "accept" "(SetPara) (done_dialog)")
  (action_tile "cancel" "(exit) (done_dialog)")
;  (action_tile "help"    "(acad_helpdlg \"/acadsst/steuerg/steuerg.hlp\" \"elektro\")")
  (action_tile "help"    "(acad_helpdlg \HIDATEI\ \"HARDWAREPLANUNG\")" )
  (start_dialog)
  (unload_dialog Dat)
)

(defun zeig_dia()
  (setq m_KOMP (get_tile "KOMP"))
  (SetVisibility)
)

(defun SetVisibility()
  (setq breite (dimx_tile "anzeige"))
  (setq hoehe  (dimy_tile "anzeige"))
  (start_image "anzeige")
  (FILL_IMAGE 0 0 breite hoehe 0)
  (if (= m_KOMP "0")                                    ; Sensor
    (progn
      (mode_tile "NULLTR" 1)
      (mode_tile "SCAN" 1)
      (mode_tile "REVERS" 1)
      (mode_tile "W1" 1)
      (mode_tile "W2" 1)
      (mode_tile "LAGE1" 1)
      (mode_tile "LAGE2" 1)
      (mode_tile "ZB" 0)
      (mode_tile "ZY" 1)
      (mode_tile "ZM" 1)
      (slide_image 0 0 breite hoehe "steuerg(sensor)")
    )
  )
  (if (= m_KOMP "1")                                     ; Ventil
    (progn
      (mode_tile "NULLTR" 1)
      (mode_tile "SCAN" 1)
      (mode_tile "REVERS" 1)
      (mode_tile "W1" 0)
      (mode_tile "W2" 1)
      (mode_tile "LAGE1" 0)
      (mode_tile "LAGE2" 1)
      (mode_tile "ZB" 1)
      (mode_tile "ZY" 0)
      (mode_tile "ZM" 1)
      (slide_image 0 0 breite hoehe "steuerg(ventil)")
    )
  )
  (if (= m_KOMP "2")                                     ; Antrieb
    (progn
      (mode_tile "NULLTR" 1)
      (mode_tile "SCAN" 1)
      (mode_tile "REVERS" 0)
      (mode_tile "W1" 1)
      (mode_tile "W2" 1)
      (mode_tile "LAGE1" 1)
      (mode_tile "LAGE2" 1)
      (mode_tile "ZB" 1)
      (mode_tile "ZY" 1)
      (mode_tile "ZM" 0)
      (slide_image 0 0 breite hoehe "steuerg(antrieb)")
    )
  )
  (if (= m_KOMP "3")                                     ; Separator
    (progn
      (mode_tile "NULLTR" 0)
      (mode_tile "SCAN" 1)
      (mode_tile "REVERS" 1)
      (mode_tile "W1" 1)
      (mode_tile "W2" 1)
      (mode_tile "LAGE1" 1)
      (mode_tile "LAGE2" 1)
      (mode_tile "ZB" 0)
      (mode_tile "ZY" 0)
      (mode_tile "ZM" 1)
      (slide_image 0 0 breite hoehe "steuerg(separat)")
    )
  )
  (if (= m_KOMP "4")                                    ; Weiche
    (progn
      (mode_tile "NULLTR" 1)
      (mode_tile "SCAN" 1)
      (mode_tile "REVERS" 1)
      (mode_tile "W1" 0)
      (mode_tile "W2" 0)
      (mode_tile "LAGE1" 0)
      (mode_tile "LAGE2" 0)
      (mode_tile "ZB" 1)
      (mode_tile "ZY" 0)
      (mode_tile "ZM" 1)
      (slide_image 0 0 breite hoehe "steuerg(weiche)")
    )
  )
  (if (= m_KOMP "5")                                     ; Scanner
    (progn
      (mode_tile "NULLTR" 1)
      (mode_tile "SCAN" 0)
      (mode_tile "REVERS" 1)
      (mode_tile "W1" 1)
      (mode_tile "W2" 1)
      (mode_tile "LAGE1" 1)
      (mode_tile "LAGE2" 1)
      (mode_tile "ZB" 0)
      (mode_tile "ZY" 0)
      (mode_tile "ZM" 1)
      (slide_image 0 0 breite hoehe "steuerg(scanner)")
    )
  )
  (if (= m_KOMP "6")                                    ; Rollenhebelschalter
    (progn
      (mode_tile "NULLTR" 1)
      (mode_tile "SCAN" 1)
      (mode_tile "REVERS" 1)
      (mode_tile "W1" 1)
      (mode_tile "W2" 1)
      (mode_tile "LAGE1" 1)
      (mode_tile "LAGE2" 1)
      (mode_tile "ZB" 0)
      (mode_tile "ZY" 1)
      (mode_tile "ZM" 1)
      (slide_image 0 0 breite hoehe "steuerg(rollenh)")
    )
  )
  (if (= m_KOMP "7") 
    (progn
      (mode_tile "NULLTR" 1)
      (mode_tile "SCAN" 1)
      (mode_tile "REVERS" 1)
      (mode_tile "W1" 1)
      (mode_tile "W2" 1)
      (mode_tile "LAGE1" 1)
      (mode_tile "LAGE2" 1)
      (mode_tile "ZB" 1)
      (mode_tile "ZY" 0)
      (mode_tile "ZM" 1)
      (slide_image 0 0 breite hoehe "steuerg(druckt)")
    )
  )
  (if (= m_KOMP "8") 
    (progn
      (mode_tile "NULLTR" 1)
      (mode_tile "SCAN" 1)
      (mode_tile "REVERS" 1)
      (mode_tile "W1" 1)
      (mode_tile "W2" 1)
      (mode_tile "LAGE1" 1)
      (mode_tile "LAGE2" 1)
      (mode_tile "ZB" 0)
      (mode_tile "ZY" 1)
      (mode_tile "ZM" 1)
      (slide_image 0 0 breite hoehe "steuerg(anzleu)")
    )
  )
  (end_image)
)

(defun SetPara ()
  (setq m_NULLTR     (get_tile "NULLTR"))
  (setq m_KOMP       (get_tile "KOMP"))
  (setq m_SCAN       (get_tile "SCAN"))
  (setq m_NORM       (get_tile "NORM"))
  (setq m_REVERS     (get_tile "REVERS"))
  (setq m_ZUSATZ     (get_tile "ZUSATZ"))
  (setq m_W1         (get_tile "W1"))
  (setq m_W2         (get_tile "W2"))
  (setq m_LAGE1      (get_tile "LAGE1"))
  (setq m_ZB         (get_tile "ZB"))
  (setq m_ZY         (get_tile "ZY"))
  (setq m_ZM         (get_tile "ZM"))
  (setq m_VAR_F      (get_tile "VAR_F"))
  (setq m_EBEN       (get_tile "EBEN"))
  (setq m_EBENE      (get_tile "A_EBENE"))
  (setq m_ORT        (get_tile "A_ORT"))
  (setq m_KLKAST     (get_tile "A_KLKAST"))
  (setq m_IBS-UV     (get_tile "A_IBS-UV"))
  (setq m_KOMMENT    (get_tile "A_KOMMENT"))
  ;-------------------------------------
  (initget (+ 2 4))
  ;---------------------------------------
)
(defun datain ()  
  ;-------------------------------------------------------
  ;>>>> Eingabeteil <<<<<<<
  ;-------------------------------------------------------
  (setq ALTFANG (getvar "osmode"))
  (initget (+ 1 2 4))
  (command "_ortho" "_off")
  (setq P0 (getpoint "\nKomponente setzen : "))
  (bl-name P0) ;--> Block-Name definieren -> Rckgabe: block-kennung
  (setq P1 (getpoint P0 "\n2.Punkt antippen: "))
  (setq P6  (list (car p1) (- (cadr p1) 75)  (caddr p1)))
  (command "_ortho" "_on")
  (setvar "osmode" 0)  
  (command "_elevation" "0")
  (command "_ucs" "_w")
  (command "_fill" "_off")
  (command "_layer" "_m" "Y-7" "_c" "7" "" "")
  (command "_line" P0 P1 "")
  (command "_circle" P1 "1")
  (setq SATZ1 (ssget "_L"))

)

(defun geometrie()
  (if (= m_KOMP "0")                               ;****** Sensor gewhlt 
    (progn
      (setq FOLIE "Y-EINGANG")
      (setq SZIN  "1")
      (if (= m_NORM "NORM_1")                     
        (setq PREFIX "B")                          ; Deutsch
        (setq PREFIX "PRS")                        ; US
      )
      (setq ALPHA (strcat m_EBEN PREFIX m_ZB))     ; Beschriftung
      ;-----------------------
      ; Properties definieren
      ;-----------------------
      (setq M_LAGE "")
      (setq M_FUNKTION "")
      (setq M_ART      "B")         ;--> Sensor
      (setq M_LFD_NR   M_ZB)        ;--> Laufendenummer - unique
      (setq M_E_A      "E")         ;--> E-Eingang / A-Ausgang
      (setq M_BENENNG  "Sensor")    ;--> Element
      (setq M_LEISTUNG "3W-0,125A") ;-->Leistungufnahme
      (setq ZAHL m_ZB)                             ; Variable vertauschen
      (pruefe_lz)                                  ; und prfen (OKTAL)
      (setq ALPHA (strcat ALPHA m_ZUSATZ))
      (setq m_ZB ZAHL)                             ; Variable vertauschen
      (kasten 0)                                   ; Rechteck zeichnen
    )
  )
  (if (= m_KOMP "1")                               ; ******* Magnetventil
    (progn
      (setq FOLIE "Y-AUSGANG")
      (setq SZIN  "3")
      (if (= m_NORM "NORM_1")
        (setq PREFIX "Y")
        (setq PREFIX "SOL")
      )
      (setq ALPHA (strcat m_EBEN PREFIX m_ZY))
      (setq M_LFD_NR   M_ZY)        ;--> Laufendenummer - unique
      (setq ZAHL m_ZY)
      (pruefe_lz)
      (if (= m_W1 "0")
        (setq DUMMY1 "")
      )
      (if (= m_W1 "1")
        (setq DUMMY1 "-G")
      )
      (if (= m_W1 "2")
        (setq DUMMY1 "-L")
      )
      (if (= m_W1 "3")
        (setq DUMMY1 "-R")
      )
      (if (= m_W1 "4")
        (setq DUMMY1 "-A")
      )
      (if (= m_W1 "5")
        (setq DUMMY1 "-Z")
      )
      (if (= m_W1 "6")
        (setq DUMMY1 "-GR")
      )
      (if (= m_LAGE1 "0")     ; kein VON / NACH erforderlich
        (setq m_LAGE "")
      )
      (if (= m_LAGE1 "1")     ; VON erforderlich
        (setq m_LAGE "V")
      )
      (if (= m_LAGE1 "2")     ; NACH erforderlich
        (setq m_LAGE "N")
      )
      (setq ALPHA (strcat ALPHA DUMMY1 m_ZUSATZ))
      (setq m_ZY ZAHL)
      ;-------------------
      ; Abfrage Properties
      ;************************************************************************
      (setq M_LAGE "")
      (setq M_FUNKTION "")
      (setq M_ART      "Y")         ;--> Sensor
      (setq M_E_A      "A")         ;--> E-Eingang / A-Ausgang
      (setq M_BENENNG  "Ventil")    ;--> Element
      (setq M_LEISTUNG "3W-0,125A") ;-->Leistungufnahme
      ;------------------------------------------------------------------------
      (setq DUMMY1 "")
      (kasten 0)
    )
  )
  (if (= m_KOMP "2")                                ; ********* Antrieb
    (progn
      (setq FOLIE "Y-4")
      (setq SZIN  "4")
      (if (= m_NORM "NORM_1")
        (setq PREFIX "M")
        (setq PREFIX "MTR")
      )
      (if (= m_REVERS "REVERS_2") ; wenn reversibel
        (setq DUMMY1 "-R")
        (setq DUMMY1 "")
      )
      (setq ALPHA (strcat m_EBEN PREFIX m_ZM))
      (setq M_LFD_NR   M_ZM)        ;--> Laufendenummer - unique
      (setq ZAHL m_ZM)
      (pruefe_lz)
      (setq ALPHA (strcat ALPHA DUMMY1 m_ZUSATZ))
      ;-------------------
      ; Abfrage Properties
      ;-------------------
      (setq M_LAGE "")
      (setq M_FUNKTION "")
      (setq M_ART      "M")         ;--> Sensor
      (setq M_E_A      "A")         ;--> E-Eingang / A-Ausgang
      (setq M_BENENNG  "Motor")    ;--> Element
      (setq M_LEISTUNG "550W-4,5A") ;-->Leistungufnahme
      ;------------------------------------------------------------------------
      (setq DUMMY1 "")
      (setq m_ZM ZAHL)
      (kasten 0)
    )
  )
  (if (or (= m_KOMP "3") (= m_KOMP "4")) ; ********* Separator oder Weiche
    ; ---------
    ; 2 Ventile
    ; --------- 
    (progn
      (setq FOLIE "Y-AUSGANG")
      (setq SZIN  "3")
      (if (= m_NORM "NORM_1") ; Deutsch
        (progn
          (setq PREFIX "Y")
          (if (= m_KOMP "3")   ; Separator DEUTSCH
            (progn
              (setq SEP1 "-A")
              (setq SEP2 "-Z")
              (setq SEP3 "-I")
              (setq SEP4 "-V")
              (setq SEP5 "-0")
              (setq DUMMY1 "")
              (setq DUMMY2 "")
            )
            (progn
              (setq SEP1 "")  ; Weiche DEUTSCH
              (setq SEP2 "")
              (setq SEP3 "")
              (setq SEP4 "")
              (setq SEP5 "")
              ;------------- Funktion des ersten Ventils -------------
              (if (= m_W1 "0")
                (setq DUMMY1 "")
              )
              (if (= m_W1 "1")
                (setq DUMMY1 "-G")
              )
              (if (= m_W1 "2")
                (setq DUMMY1 "-L")
              )
              (if (= m_W1 "3")
                (setq DUMMY1 "-R")
              )
              (if (= m_W1 "4")
                (setq DUMMY1 "-A")
              )
              (if (= m_W1 "5")
                (setq DUMMY1 "-Z")
              )
              (if (= m_W1 "6")
                (setq DUMMY1 "-GR")
              )
              ;---- Lage definieren ---------------------------------
              (if (= m_LAGE1 "0")     ; kein VON / NACH erforderlich
                (setq m_LAGE "")
              )
              (if (= m_LAGE1 "1")     ; VON erforderlich
                (setq m_LAGE "V")
              )
              (if (= m_LAGE1 "2")     ; NACH erforderlich
                (setq m_LAGE "N")
              ) 
              ;----- Funktion des zweiten Ventils ---------------------
              (if (= m_W2 "0")
                (setq DUMMY2 "")
              )
              (if (= m_W2 "1")
                (setq DUMMY2 "-G")
              )
              (if (= m_W2 "2")
                (setq DUMMY2 "-L")
              )
              (if (= m_W2 "3")
                (setq DUMMY2 "-R")
              )
              (if (= m_W2 "4")
                (setq DUMMY2 "-A")
              )
              (if (= m_W2 "5")
                (setq DUMMY2 "-Z")
              )
              (if (= m_W2 "6")
                (setq DUMMY2 "-GR")
              )
            )
          )
        )
        (progn
          (setq PREFIX "SOL")
          (if (= m_KOMP "3")
            (progn
              (setq SEP1 "-O")  ; Separator US
              (setq SEP2 "-C")
              (setq SEP3 "-I")
              (setq SEP4 "-L")
              (setq SEP5 "-0")
              (setq DUMMY1 "")
              (setq DUMMY2 "")
            )
            (progn
              (setq SEP1 "")    ; Weiche US
              (setq SEP2 "")
              (setq SEP3 "")
              (setq SEP4 "")
              (setq SEP5 "")
              (if (= m_W1 "0")
                (setq DUMMY1 "")
              )
              (if (= m_W1 "1")
                (setq DUMMY1 "-S")
              )
              (if (= m_W1 "2")
                (setq DUMMY1 "-L")
              )
              (if (= m_W1 "3")
                (setq DUMMY1 "-R")
              )
              (if (= m_W1 "4")
                (setq DUMMY1 "-O")
              )
              (if (= m_W1 "5")
                (setq DUMMY1 "-C")
              )
              (if (= m_W1 "6")
                (setq DUMMY1 "-GI")
              )
              (if (= m_W2 "0")
                (setq DUMMY2 "")
              )
              (if (= m_W2 "1")
                (setq DUMMY2 "-S")
              )
              (if (= m_W2 "2")
                (setq DUMMY2 "-L")
              )
              (if (= m_W2 "3")
                (setq DUMMY2 "-R")
              )
              (if (= m_W2 "4")
                (setq DUMMY2 "-O")
              )
              (if (= m_W2 "5")
                (setq DUMMY2 "-C")
              )
              (if (= m_W2 "6")
                (setq DUMMY2 "-GI")
              )
            )
          )
        )
      )
      (setq ALPHA (strcat m_EBEN PREFIX m_ZY))
      ;-------------------
      ; Abfrage Properties  - Ventile
      ;***********************************************************************
      (if (= m_KOMP "4")  ; Weiche
        (setq M_FUNKTION (substr DUMMY1 2))
        (setq M_FUNKTION SEP1)
      )
      (setq M_ART      "Y")         ;--> Ventil
      (setq M_LFD_NR   M_ZY)        ;--> Laufendenummer - unique
      (setq M_E_A      "A")         ;--> E-Eingang / A-Ausgang
      (if (= m_KOMP "3")
        (setq M_BENENNG  "Ventil-Separator")    ;--> Element
        (setq M_BENENNG  "Ventil-Weiche")    ;--> Element
      )
      (setq M_LEISTUNG "3W-0,125A") ;-->Leistungufnahme
      ;***********************************************************************
      (setq ZAHL m_ZY)
      (pruefe_lz)
      (setq ALPHA (strcat ALPHA SEP1 DUMMY1 m_ZUSATZ))
      (setq m_ZY ZAHL)
      (kasten 0)
      (setq DUMMY1 "")
      (setq P6  (list (car p6) (- (cadr p6) 150) (caddr p6)))
      (setq ALPHA (strcat m_EBEN PREFIX m_ZY))
      (if (= m_KOMP "4")  ; Weiche
        (setq M_FUNKTION (substr DUMMY2 2))
        (setq M_FUNKTION SEP2)
      )
      (setq M_LFD_NR   M_ZY)        ;--> Laufendenummer - unique
      (setq ZAHL m_ZY)
      (pruefe_lz)
      (setq ALPHA (strcat ALPHA SEP2 DUMMY2 m_ZUSATZ))
      (setq m_ZY ZAHL)
      (kasten 0)
      (setq DUMMY2 "")
    )
  )  
  (if (= m_KOMP "3")  ; nur frs Separator
      ; ---------------------
      ; 2 Sensoren erstellen
      ; ---------------------
    (progn
      (setq P6  (list (car p6) (- (cadr p6) 150) (caddr p6)))
      (setq FOLIE "Y-EINGANG")
      (setq SZIN  "1")
      (if (= m_NORM "NORM_1")
        (setq PREFIX "B")
        (setq PREFIX "PRS")
      )
      (setq ALPHA (strcat m_EBEN PREFIX m_ZB))
      ;**********************************************************************
      (setq M_ART      "B")                    ;--> Sensor
      (setq M_E_A      "E")                    ;--> E-Eingang / A-Ausgang
      (setq M_FUNKTION "I")                    ;--> Funktion
      (setq M_BENENNG  "Sensor-Separator")     ;--> Element
      (setq M_LFD_NR   M_ZB)                   ;--> Laufendenummer - unique
      ;**********************************************************************
      (setq ZAHL m_ZB)
      (pruefe_lz)
      (setq ALPHA (strcat ALPHA SEP3 m_ZUSATZ))
      (setq m_ZB ZAHL)
      (kasten 0)
      (setq P6  (list (car p6) (- (cadr p6) 150) (caddr p6)))
      (setq ALPHA (strcat m_EBEN PREFIX m_ZB))
      ;*********************************************************************
      (setq M_FUNKTION "V")         ;--> Funktion
      (setq M_LFD_NR   M_ZB)        ;--> Laufendenummer - unique
      ;*********************************************************************
      (setq ZAHL m_ZB)
      (pruefe_lz)
      (setq ALPHA (strcat ALPHA SEP4 m_ZUSATZ))
      (setq m_ZB ZAHL)
      (kasten 0)
      (if (= m_NULLTR "NULLTR_1")  ; Separator mit NULL-BT Erkennung
        (progn
          (setq P6  (list (car p6) (- (cadr p6) 150) (caddr p6)))
          (setq ALPHA (strcat m_EBEN PREFIX m_ZB))
          ;**********************************************************
          (setq M_FUNKTION "0")         ;--> Funktion
          (setq M_LFD_NR   M_ZB)        ;--> Laufendenummer - unique
          ;**********************************************************
          (setq ZAHL m_ZB)
          (pruefe_lz)
          (setq ALPHA (strcat ALPHA SEP5 m_ZUSATZ))
          (setq m_ZB ZAHL)
          (kasten 0)
        )
      )
    )
  )
  (if (= m_KOMP "5") ;                     ***************** Scanner
    (progn
      ;--> Scannerkasten zeichnen
      (if (= m_NORM "NORM_1") ; Deutsch
        (progn
          (setq INP1 "E")
          (setq INP2 "A")
        )
        (progn
          (setq INP1 "I")
          (setq INP2 "O")
        )
      )
      (if (= m_SCAN "SCAN_1")  ; Scanner fr BT
        (setq SC_NAME "SC")
      )
      (if (= m_SCAN "SCAN_2")  ; Kleidungsscanner automatisch
        (setq SC_NAME "SCC")
      )
      (if (= m_SCAN "SCAN_3")  ; Kleidungsscanner manuell
        (setq SC_NAME "SCM")
      )
      (setq ALPHA SC_NAME)
      (setq FOLIE "Y-7")
      (setq SZIN  "7")
      (setq ALPHA (strcat m_EBEN SC_NAME))
      (setq ANZ_CHAR (strlen ALPHA))
      (kasten 1)
      ;--> Eingang zeichnen
      (setq DUMMY1 "")
      (setq DUMMY2 "")
      (setq P6  (list (car p6) (- (cadr p6) 150) (caddr p6)))
      (setq PREFIX "E")
      (setq ALPHA (strcat m_EBEN INP1 m_ZB))
      ;*******************
      ; Abfrage Properties 
      ;******************************************************************
      (setq M_LAGE "")
      (setq M_FUNKTION "")
      (setq M_ART      "E")                  ;--> Sensor
      (setq M_LFD_NR    M_ZB)                ;--> Laufendenummer - unique
      (setq M_E_A      "E")                  ;--> E-Eingang / A-Ausgang
      (setq M_BENENNG  "Eingang Scanner")    ;--> Element
      (setq M_LEISTUNG "3W-0,125A")          ;--> Leistungufnahme
      ;*******************************************************************
      (setq ZAHL m_ZB)
      (pruefe_lz)
      (setq ALPHA (strcat ALPHA m_ZUSATZ))
      (setq m_ZB ZAHL)
      (setq FOLIE "Y-EINGANG")
      (setq SZIN  "1")
      (kasten 0)
      ;--> Ausgang 1 
      (setq P6  (list (car p6) (- (cadr p6) 150) (caddr p6)))
      (setq ALPHA (strcat m_EBEN INP2 m_ZY))
      ;*******************************************************************
      (setq M_ART      "A")                  ;--> Ausgang
      (setq M_LFD_NR    M_ZY)                ;--> Laufendenummer - unique
      (setq M_E_A      "A")                  ;--> E-Eingang / A-Ausgang
      (setq M_BENENNG  "Ausgang1 Scanner")   ;--> Element
      (setq M_LEISTUNG "3W-0,125A")          ;--> Leistungufnahme
      ;*******************************************************************
      (setq ZAHL m_ZY)
      (pruefe_lz)
      (setq ALPHA (strcat ALPHA m_ZUSATZ))
      (setq m_ZY ZAHL)
      (setq FOLIE "Y-AUSGANG")
      (setq SZIN  "3")
      (kasten 0)
      ;--> Ausgang 2
      (setq P6  (list (car p6) (- (cadr p6) 150) (caddr p6)))
      (setq ALPHA (strcat m_EBEN INP2 m_ZY))
      ;*******************************************************************
      (setq M_ART      "A")                  ;--> Ausgang
      (setq M_LFD_NR    M_ZY)                ;--> Laufendenummer - unique
      (setq M_E_A      "A")                  ;--> E-Eingang / A-Ausgang
      (setq M_BENENNG  "Ausgang2 Scanner")   ;--> Element
      (setq M_LEISTUNG "3W-0,125A")          ;--> Leistungufnahme
      ;*******************************************************************
      (setq ZAHL m_ZY)
      (pruefe_lz)
      (setq ALPHA (strcat ALPHA m_ZUSATZ))
      (setq m_ZY ZAHL)
      (kasten 0)
    )
  )
  (if (or (= m_KOMP "6") (= m_KOMP "7") (= m_KOMP "8")) 
    (progn                                               
      (if (= m_KOMP "6")              ; ************** Rollenhebelschalter
        (progn
          ;-------------------
          ; Abfrage Properties
          ;-------------------
          (setq M_LAGE "")
          (setq M_FUNKTION "")
          (setq M_ART      "E")                  ;--> Sensor
          (setq M_LFD_NR    M_ZB)                ;--> Laufendenummer - unique
          (setq M_E_A      "E")                  ;--> E-Eingang / A-Ausgang
          (setq M_BENENNG  "Rollenhebelschalter");--> Element
          (setq M_LEISTUNG "3W-0,125A")          ;--> Leistungufnahme
          ;------------------------------------------------------------------------
          (setq FOLIE "Y-EINGANG")
          (setq SZIN  "1")
          (if (= m_NORM "NORM_1")
            (setq PREFIX "RS")
            (setq PREFIX "RS")   ; fr US noch ndern !!
          )
        )
      )
      (if (= m_KOMP "7")                                ; Drucktaster
        (progn
          ;-------------------
          ; Abfrage Properties
          ;-------------------
          (setq M_LAGE "")
          (setq M_FUNKTION "")
          (setq M_ART      "E")
          (setq M_LFD_NR    M_ZB)                ;--> Laufendenummer - unique
          (setq M_E_A      "E")                  ;--> E-Eingang / A-Ausgang
          (setq M_BENENNG  "Drucktaster");--> Element
          (setq M_LEISTUNG "3W-0,125A")          ;--> Leistungufnahme
          ;------------------------------------------------------------------------
          (setq FOLIE "Y-EINGANG")
          (setq SZIN  "1")
          (if (= m_NORM "NORM_1")
            (setq PREFIX "S")
            (setq PREFIX "S")   ; fr US noch ndern !!
          )
        )
      )
      (if (= m_KOMP "8")                                ; Anzeigeleuchte
        (progn
          ;-------------------
          ; Abfrage Properties
          ;-------------------
          (setq M_LAGE "")
          (setq M_FUNKTION "")
          (setq M_ART      "A")                  ;--> Sensor
          (setq M_LFD_NR    M_ZY)                ;--> Laufendenummer - unique
          (setq M_E_A      "A")                  ;--> E-Eingang / A-Ausgang
          (setq M_BENENNG  "Anzeigeleuchte")     ;--> Element
          (setq M_LEISTUNG "3W-0,125A")          ;--> Leistungufnahme
          ;------------------------------------------------------------------------
          (setq FOLIE "Y-AUSGANG")
          (setq SZIN  "3")
          (if (= m_NORM "NORM_1")
            (setq PREFIX "H")
            (setq PREFIX "H")   ; fuer US noch aendern !!
          )
        )
      )
      (if (or (= m_KOMP "6") (= m_KOMP "7"))   ; Anzahl Eingaenge erhoehen
        (progn
          (setq ALPHA (strcat m_EBEN PREFIX m_ZB))
          (setq ZAHL m_ZB)
          (pruefe_lz)
          (setq ALPHA (strcat ALPHA m_ZUSATZ))
          (setq m_ZB ZAHL)
        )
      )
      (if (= m_KOMP "8")                            ; Anzahl Ausgaenge erhoehen
        (progn
          (setq ALPHA (strcat m_EBEN PREFIX m_ZY))
          (setq ZAHL m_ZY)
          (pruefe_lz)
          (setq ALPHA (strcat ALPHA m_ZUSATZ))
          (setq m_ZY ZAHL)
        )
      )
      (kasten 0)
    )
  )
)

(defun pruefe_lz ()
  (setq ANZ_CHAR (strlen ALPHA))
  (if (or (= (substr ALPHA ANZ_CHAR 1) "8") (= (substr ALPHA ANZ_CHAR 1) "9"))
    (progn
      (alert "Letztes Zeichen der Kette ist falsch !!")    
      (command "_erase" "_l" "")
      (setq SATZ1 nil)
      (exit)
    )
  )
  (setq ZAHL (itoa (+ (atoi ZAHL) 1)))    ; um 1 erhhen und 
  (setq PRUF_LZ (strlen ZAHL))            ; das Ergebnis der Erhhung
  (if (= (substr ZAHL PRUF_LZ 1) "8")   ; prfen und gegebenenfalls
    (setq ZAHL (itoa (+ (atoi ZAHL) 2)))  ; korrigieren, um auf OKTAL-    
  )                                       ; code zu kommen
  (if (= (substr ZAHL PRUF_LZ 1) "9")
    (setq ZAHL (itoa (+ (atoi ZAHL) 1)))    
  )
)

(defun kasten(mit_prop)
  (command "_layer" "_m" "Y-7" "_c" "7" "" "")
  (setq ANZ_CHAR (strlen ALPHA))
  (setq P3  (list (+ (car p6) (* ANZ_CHAR 105)) (+ (cadr p6) 150) (caddr p6)))
  (setq P4  (list (+ (car p6) (* ANZ_CHAR 105)) (cadr p6)         (caddr p6)))
  (setq P5  (list (car p6)                      (+ (cadr p6) 150) (caddr p6)))
  (setq P2  (list (+ (car p6) 20)               (+ (cadr p6)  20) (caddr p6)))
  (command "_pline" P6 P4 P3 P5 P6 "")
  (ssadd (entlast) SATZ1)  
;  (block-op P0 "0" SATZ1) 
  (command "_layer" "_m" FOLIE "_c" SZIN "" "")
  (command "_text" "_s" "STANDARD" P2 "100" "0" ALPHA)
  (setq auswahl-satz (ssget "_L"))   ; Properties dem Text zuordnen
  (if (= mit_prop 0)
    (property)
  )
  (ssadd (entlast) SATZ1)  
)

(defun property()
  ;------------------
  ; Block definieren
  ;-----------------------------------------------------------
  ;           P2     - Origin der Baugruppe
  ;           szoeg   - Einfuegewinkel
  ;  auswahl-satz     - Elemente des Blockes in Auswahlsatz   
  ;------------------------------------------------------------
  (setq komponente1 (strcat (itoa (abs (fix (car P2)))) (itoa (abs (fix (cadr P2))))
		    (itoa (abs (fix (caddr P2))))))
;  (setq komponente2 szoeg)
  (setq komponente2 "0")
  (setq seconds (substr (rtos (getvar "cdate") 2 9) 10 9))
  (setq element-name (strcat komponente1 komponente2 seconds))
  (princ)
  (princ (strcat komponente1 "\n"))
  (princ (strcat komponente2 "\n"))
  (princ (strcat seconds "\n"))
  (princ)
  (princ (strcat "\n" element-name "\n"))
  (princ)
  (setq gefunden (tblsearch "block" element-name))
  (if (not gefunden)
     (progn
	 (princ)
	 (command "_insert" (strcat "*" lw "/acadsst/menu/EBENE") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
 	 (command "_insert" (strcat "*" lw "/acadsst/menu/ART") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
	 (command "_insert" (strcat "*" lw "/acadsst/menu/LFD_NR") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
	 (command "_insert" (strcat "*" lw "/acadsst/menu/LAGE") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
	 (command "_insert" (strcat "*" lw "/acadsst/menu/FUNKTION") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
	 (command "_insert" (strcat "*" lw "/acadsst/menu/E_A") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
	 (command "_insert" (strcat "*" lw "/acadsst/menu/BYTE_BIT") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
	 (command "_insert" (strcat "*" lw "/acadsst/menu/BENENNG") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
	 (command "_insert" (strcat "*" lw "/acadsst/menu/LEISTUNG") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
	 (command "_insert" (strcat "*" lw "/acadsst/menu/ORT") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
	 (command "_insert" (strcat "*" lw "/acadsst/menu/KLKAST") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
	 (command "_insert" (strcat "*" lw "/acadsst/menu/IBS-UV") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
	 (command "_insert" (strcat "*" lw "/acadsst/menu/KOMMENT") P2 "" "")
	 (ssadd (entlast) auswahl-satz)
	 (command "_block" element-name P2 auswahl-satz "")
	 (command "_insert" element-name P2 "" "" "0")
         (PROPERTY-AENDERN M_EBENE M_ART M_LFD_NR M_LAGE M_FUNKTION  
                          M_E_A M_BENENNG M_LEISTUNG M_ORT M_KLKAST 
                          M_IBS-UV M_KOMMENT)
     )
     (alert "\nBlockname existiert. Bitte A. Walz benachrichtigen. 
               Das Programm muá gendert werden !")
  )
)

(defun PROPERTY-AENDERN ( M_EBENE M_ART M_LFD_NR M_LAGE M_FUNKTION  
                          M_E_A M_BENENNG M_LEISTUNG M_ORT M_KLKAST M_IBS-UV
                          M_KOMMENT 
                          / objekt typ attribut-bezeichnung attribut-wert)
  (setq objekt (entlast))
  (while (not (equal 
		(cdr (assoc 0 (entget objekt)))
		"SEQEND"))
    (setq typ
      (cdr (assoc 0 (entget objekt))))
    (if
      (equal typ "ATTRIB")
      (progn
	(setq ATTRIBUT-BEZEICHNUNG (cdr (assoc 2 (entget objekt))))
	(setq ATTRIBUT-WERT        (cdr (assoc 1 (entget objekt))))
	(if (and (> (strlen M_EBENE) 0) (equal ATTRIBUT-BEZEICHNUNG "EBENE"))
	     (entmod (subst (cons 1 M_EBENE) (assoc 1 (entget objekt))
		     (entget objekt)))
	)
	(if (and (> (strlen M_ART) 0) (equal ATTRIBUT-BEZEICHNUNG "ART"))
	     (entmod (subst (cons 1 M_ART) (assoc 1 (entget objekt))
		     (entget objekt)))
	)
	(if (and (> (strlen M_LFD_NR) 0) (equal ATTRIBUT-BEZEICHNUNG "LFD_NR"))
	     (entmod (subst (cons 1 M_LFD_NR) (assoc 1 (entget objekt))
		     (entget objekt)))
	)
	(if (and (> (strlen M_LAGE) 0) (= ATTRIBUT-BEZEICHNUNG "LAGE"))
	     (entmod (subst (cons 1 M_LAGE) (assoc 1 (entget objekt))
		     (entget objekt)))
	)
	(if (and (> (strlen M_FUNKTION) 0) (= ATTRIBUT-BEZEICHNUNG "FUNKTION"))
	     (entmod (subst (cons 1 M_FUNKTION) (assoc 1 (entget objekt))
		     (entget objekt)))
	)
	(if (and (> (strlen M_E_A) 0) (equal ATTRIBUT-BEZEICHNUNG "E_A"))
	     (entmod (subst (cons 1 M_E_A) (assoc 1 (entget objekt))
		     (entget objekt)))
	)
	(if (and (> (strlen M_BENENNG) 0) (equal ATTRIBUT-BEZEICHNUNG "BENENNG"))
	     (entmod (subst (cons 1 M_BENENNG) (assoc 1 (entget objekt)) 
                     (entget objekt)))
	)
	(if (and (> (strlen M_LEISTUNG) 0) (equal ATTRIBUT-BEZEICHNUNG "LEISTUNG"))
	     (entmod (subst (cons 1 M_LEISTUNG)
		     (assoc 1 (entget objekt)) (entget objekt)))
	)
	(if (and (> (strlen M_ORT) 0) (equal ATTRIBUT-BEZEICHNUNG "ORT"))
	     (entmod (subst (cons 1 M_ORT) (assoc 1 (entget objekt))
		     (entget objekt)))
	)
	(if (and (> (strlen M_KLKAST) 0) (equal ATTRIBUT-BEZEICHNUNG "KLKAST"))
	     (entmod (subst (cons 1 M_KLKAST) (assoc 1 (entget objekt))
		     (entget objekt)))
	)
	(if (and (> (strlen M_IBS-UV) 0) (equal ATTRIBUT-BEZEICHNUNG "IBS-UV"))
	     (entmod (subst (cons 1 M_IBS-UV) (assoc 1 (entget objekt))
		     (entget objekt)))
	)
	(if (and (> (strlen M_KOMMENT) 0) (equal ATTRIBUT-BEZEICHNUNG "KOMMENT"))
	     (entmod (subst (cons 1 M_KOMMENT)
		     (assoc 1 (entget objekt)) (entget objekt)))
	)
      )  ; Ende ----progn
    )    ; Ende ----if
    (setq objekt (entnext objekt))
  )
  (setq objekt objekt)
)

;------------------------------------------------------------------------------
(defun c:elektro ( / NULLTR NULLTR_1 NULLTR_2 KOMP SCAN NORM P0 P1 P2 P3 P4 
                     P5 P6 ZB ZY ZM PREFIX SUFIX ALPHA1 ALPHA ANZ_CHAR VAR_F 
                     VAR_Z SEP1 SEP2 SEP3 SEP4 SEP5 INP1 INP2 SC_NAME EBEN
                     ZAHL REVERS REVERS_1 REVERS_2 SCAN_1 SCAN_2 SCAN_3 ZUSATZ 
                     W1 W2 LAGE1 DUMMY1 DUMMY2 FOLIE SZIN MIT_PROP A_EBENE 
                     A_ORT A_KLKAST A_IBS-UV A_KOMMENT)
  (setvar "limcheck" 0)
  (setq SATZ1 nil)
  (setq HIDATEI (strcat lw "/acadsst/steuerg/steuerg.hlp"))
  (prompt "******* HFS 2100 ELEKTRO-LAYOUT *******")
  (prompt "")
  (if (null m_NULLTR)   (setq m_NULLTR "NULLTR_1")) ; mit NULL-Trolley Erkennung
  (if (null m_KOMP)     (setq m_KOMP   "0"))        ; Komponente (Sensor def.)
  (if (null m_SCAN)     (setq m_SCAN   "SCAN_1"))   ; Scannerart
  (if (null m_NORM)     (setq m_NORM   "NORM_1"))   ; Norm (Deutsch default)
  (if (null m_REVERS)   (setq m_REVERS "REVERS_1")) ; Antrieb reversibel (NICHT)
  (if (null m_W1)       (setq m_W1 "0"))            ; Beschriftung 1. Weiche
  (if (null m_W2)       (setq m_W2 "0"))            ; Beschriftung 2. Weiche
  (if (null m_LAGE1)    (setq m_LAGE1 "0"))         ; 1. Weiche auf VON stellen
  (if (null m_ZB)       (setq m_ZB     "0"))        ; Zaehler Sensor (Eingaenge)
  (if (null m_ZY)       (setq m_ZY     "0"))        ; Zaehler Ventil (Ausgaenge)
  (if (null m_ZM)       (setq m_ZM     "0"))        ; Zaehler Motor
  (if (null m_VAR_F)    (setq m_VAR_F  "1"))        ; Varia-Faktor
  (if (null m_EBEN)     (setq m_EBEN  ""))          ; Praefix-Bezeichnung
  (if (null m_ZUSATZ)   (setq m_ZUSATZ ""))         ; Sufix
  ;----------- Variablen fuer die Properties
  (if (null m_EBENE)    (setq m_EBENE ""))
  (if (null m_ART)      (setq m_ART ""))
  (if (null m_LFD_NR)   (setq m_LFD_NR ""))
  (if (null m_LAGE)     (setq m_LAGE "")) 
  (if (null m_FUKTION)  (setq m_FUNKTION ""))
  (if (null m_E_A)      (setq m_E_A ""))
  (if (null m_BENENNG)  (setq m_BENENNG ""))
  (if (null m_LEISTUNG) (setq m_LEISTUNG "")) 
  (if (null m_ORT)      (setq m_ORT ""))
  (if (null m_KLKAST)   (setq m_KLKAST ""))
  (if (null m_IBS-UV)   (setq m_IBS-UV ""))
  (if (null m_KOMMENT)  (setq m_KOMMENT ""))
  ;------------------------------------------
  (Dbox)
  (datain)
  (geometrie)
  (if (/= m_VAR_F "1")
    (progn
      (command "_scale" SATZ1 "" P1 m_VAR_F)
      (command "_rotate" SATZ1 "" P1 pause)
    )
    (progn
      (command "_rotate" SATZ1 "" P1 pause)
;      (command "_explode" SATZ1)
    )
  )
;  (block-op P0 "0" SATZ1) 
  (setq SATZ1 nil)
  (setvar "osmode" ALTFANG)
  (command "_thickness" "0")
  (command "_elevation" "0")
)
