home *** CD-ROM | disk | FTP | other *** search
/ Current Shareware 1994 January / SHAR194.ISO / cad_util / v8n7_cad.zip / READINFO.LSP < prev    next >
Lisp/Scheme  |  1993-07-26  |  2KB  |  48 lines

  1. (defun C:READINFO ()
  2. ; open the data file
  3.   (setq f (open "XDATA.TXT" "r"))
  4.   (setq record (read-line f))
  5.   (while record
  6. ; parse the line for commas and assign variables
  7.     (setq i 1  ip 1)
  8.     (while (/= (substr record i 1) ",") (setq i (1+ i)) )
  9.     (setq roomno (substr record ip (- i ip))  i (1+ i) ip i)
  10.     (while (/= (substr record i 1) ",") (setq i (1+ i)) )
  11.     (setq blhand (substr record ip (- i ip))  i (1+ i) ip i)
  12.     (while (/= (substr record i 1) ",") (setq i (1+ i)) )
  13.     (setq blname (substr record ip (- i ip))  i (1+ i) ip i)
  14.     (setq blptno (substr record ip))            
  15. ; filter for text room number with Xdata
  16.     (setq ss1 (ssget "X" (list '(0 . "TEXT") (cons 1 roomno)))
  17.           elist (entget (setq ename (ssname ss1 0)) '("COSTLY_INVENTORY"))
  18.           xlist (cadr (assoc -3 elist)) )
  19. ; filter for handles and compare block names
  20.     (setq i 1)
  21.     (while (< i (length xlist))
  22.       (if (= (car (nth i xlist)) 1005)
  23.         (progn
  24.           (setq oblname (cdr (nth (1+ i) xlist))
  25.                 bllist (entget (handent (cdr (nth i
  26.                   xlist)))))
  27. ; if block names are different
  28.           (if (and (= (cdr (assoc 5 bllist)) blhand)
  29.                    (/= (cdr (assoc 2 bllist)) blname) )
  30.             (progn
  31.               (setq xlist (subst blname (cdr (nth (1+ i)
  32.                  xlist)) xlist))
  33.               (setq bllist (subst (cons 2 blname) (assoc 2
  34.                  bllist) bllist))
  35.               (entmod bllist)
  36.           ) ); if, progn
  37.       ) ); progn for handle
  38.       (setq i (1+ i))
  39.     ); while xlist
  40. ; update the xdata on room number
  41.     (setq elist (subst (list -3 xlist) (assoc -3 elist) elist))
  42.     (entmod elist)
  43.     (setq record (read-line f))
  44.   ); while record
  45.   (close f)
  46.   (prin1)
  47. )
  48.