Author Topic: Check for Linetype  (Read 1594 times)

0 Members and 1 Guest are viewing this topic.

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Check for Linetype
« on: August 01, 2006, 01:17:50 PM »
In this post http://www.theswamp.org/index.php?topic=10923.msg137954#msg137954 I had a question about checking for a linetype.  Well with CABs help I finally use this.  I know it can be made more efficient that is the reason for posting.  Please post some input.

code below
Code: [Select]
;;;
;;; Timothy G. Spangler
;;;
;;; ------------ Checks to see if a linetype is availible
(defun FIND_LINETYPE(LineType / Files)

(setq Files (GET_LINETYPE_FILES))
  (vl-some '(lambda(x) (if (CHECK_LINETYPE (findfile x) LineType) x)) Files)
)
(defun CHECK_LINETYPE (LINFile Linetype / OpenFile LineNumber CurrentLine Result)

(setq OpenFile (open LINFile "r"))
(while (setq CurrentLine (read-line OpenFile))
(if (wcmatch CurrentLine "`**")
(progn
(setq LinetypeName (substr(car(TGS:Stringtolist CurrentLine ","))2))
(if (= (strcase Linetype) LinetypeName)
(setq Result T)
)
)
)
)
(close OpenFile)
Result
)
(defun GET_LINETYPE_FILES (/ AcadTemp Dir)

;;; gets a list of all directories in the support path
(setq AcadTemp (reverse(STRING_TO_LIST (getenv "ACAD")";")))

;;; creates a list of all files with the ".ext" in the support path
(foreach X AcadTemp
(setq Dir (vl-string-translate  "\\" "/" X))
(if (vl-directory-files Dir "*.lin" 1)
(foreach Y (vl-directory-files Dir "*.lin" 1)
(setq LINFileList (cons Y LINFileList))
)
)
)
;;; return the list
LINFileList
)

load it type (find_linetype "linetype")
It will search all .lin files in your search path if it finds it it will return the file it is in.

I have also thought about making it more ambiguous.  use it to search any file type for anything (just a thought)

Anyway here it is, help make it more efficient.
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016