 ; Write entity data to a file in the form the drawing editor uses.
 ; Copyright 1992  Rocket software
 ; Make your own DXf files.  (Or something like them.)
 ; Getting the information back into a drawing is your own problem.
 (defun C:FILO (/ aa ss fn ff nnn bb follow)
  (write-line "Select entities to file: ")
  (setq ss (ssget))
  (setq fn (getstring T "Filename or <Return> to write to screen: "))
  (if (= fn "")
      (setq fn ())
      (progn
           (setq ff (open fn "w"))
           (close ff)))
  (setq nnn 0)
  (setq aa (ssname ss nnn))
  (while aa
         (setq bb aa)                             ; save entity name to bb
         (setq aa (entget aa))                    ; get entity data
         (if (and fn (setq ff (open fn "a")))     ; if filename & can be opened
             (progn
                  (if follow (princ "  " ff))     ; indent subentities
                  (prin1 aa ff)                   ; then write data to file
                  (write-line "" ff)              ; insert cr-lf
                  (close ff))                     ; and close it.
             (print aa))                          ; else write data to screen.
         (if (= (cdr (assoc 66 (entget bb))) 1)   ; if entities follow
                  (setq follow T))                ; set flag.
         (if (= (cdr (assoc 0 (entget bb))) "SEQEND") ; if end of ent
             (setq follow ()))                    ; clear flag.
         (if follow                               ; if flag set
             (setq aa (entnext bb))               ;   get next entity
             (progn                               ; if flag not set
                  (setq nnn (1+ nnn))             ;   increment counter
                  (setq aa (ssname ss nnn)))))    ;   and get next entity.
  (princ))