; --------------------------------------------------------------
; Positionsnummerzeichnen AW 1.5.93
; --------------------------------------------------------------

(defun c:pos_zei ()
  (command "_layer" "_m" "L-7" "_c" "7" "" "")
  (Setvar "Cmdecho" 0)
  (If (= EFNAM nil) (Setq EFNAM ""))
  (Setq X (Getstring (Strcat "\nName der ASCII-Datei: <"
    EFNAM ">: ")))
  (If (/= X "") (Setq EFNAM X))
  (Setq EFPNT (Open EFNAM "r"))
  (If
    (= EFPNT nil)
      (Princ (Strcat "\n"(Chr 34) EFNAM (Chr 34) 
                     ": Datei kann nicht ge”ffnet werden!"))
      (Progn
        (Setq CRNTL (Read-line EFPNT))
        (Setq CRNTL (Read-line EFPNT))  ;damit wird die 1.Zeile bersprungen!
        (if CRNTL 
           (princ (strcat CRNTL "\n"))
        )
        (While CRNTL
            (setq POSNR   (atof (substr CRNTL 2  5 )))
            (setq POS-X   (atof (substr CRNTL 39 11)))      
            (setq POS-Y   (atof (substr CRNTL 51 11)))
            (setq POS-Z   (atof (substr CRNTL 63 11)))
            (setq PT0 (list POS-X POS-Y POS-Z))
            (setq PT1 (list (+ POS-X 100) (+ POS-Y 200) POS-Z))
            (setq PT2 (list (+ (car PT1) 250) (cadr PT1) (caddr PT1)))
            (setq PT3 (list (car PT2) (+ (cadr PT2) 175) (caddr PT1)))
            (setq PT4 (list (car PT1) (cadr PT3)         (caddr PT1)))
            (setq PT5 (list (+ POS-X 125) (+ POS-Y 225) POS-Z))
            (command "_line" PT0 PT1 PT2 PT3 PT4 PT1 "")
            (command "_text" PT5 "100" "0" (rtos POSNR))
            (Setq CRNTL (Read-line EFPNT))
            (if CRNTL
               (princ (strcat CRNTL "\n"))
            )
        )
        (Close EFPNT)
      )
  )
  (Princ)
)

;              (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 (equal ATTRIBUT-BEZEICHNUNG "POSITION")
;                       (progn
;                         (entmod (subst (cons 1 POSITI) (assoc 1 (entget objekt))
;                         (entget objekt)))
;	                )
;                     )
;                   )
;                 )
;              )