Author Topic: Linetype from ?.lin file  (Read 4559 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Linetype from ?.lin file
« Reply #15 on: November 22, 2005, 09:17:40 PM »
And to take one more step closer.

Code: [Select]
(defun c:test ()
  (get-file-of-linetype "center")
)

(defun get-file-of-linetype (lt-name / lt-list file-names)
  (setq lt-name (strcase lt-name))
  (if (setq lt-list (get-line-types))
    (foreach file-list lt-list
      (if (member lt-name (mapcar 'strcase (cadr file-list)))
        (setq file-names (cons (car file-list) file-names))
      )
    )
  )
  file-names
)



;;  CAB 11/22/2005
;;  returns a list of all linetypes found in all .lin files found
(defun get-line-types (/ path paths fname fnames fnamelist ltnames linetypelist
                      )

  (defun getlinetypes (filename / file line str lst)
    (if (setq file (open (findfile filename) "r"))
      (progn
        (while (setq line (read-line file))
          (if (wcmatch line "`**")
            (setq str (substr (substr line 1 (vl-string-search "," line)) 2)
                  lst (cons str lst)
            )
          )
        )
        (close file)
      )
    )
    (reverse lst)
  )


  ;;   get a list of all ACAD paths
  ;;  removes "." ".." and needs error checking
  (setq paths (cdr (cdr (vl-directory-files nil nil -1))))

  ;;  get a list of all file names .lin
  (foreach path paths
    (if (setq fnames (vl-directory-files path "*.lin"))
      (setq fnamelist (append fnames fnamelist))
    )
  )

  (foreach fname fnamelist
    (if (setq ltnames (getlinetypes fname))
      (setq linetypelist (cons (list fname ltnames) linetypelist))
    )
  )

  (princ)
  linetypelist
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.