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

0 Members and 1 Guest are viewing this topic.

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Linetype from ?.lin file
« on: November 21, 2005, 12:34:41 PM »
Is there a way the tell what .lin file a loaded linetype came from?

[example]

In a drawing I have a line type called "Cable" this linetype came from "Tele.lin" file.

[/example]

Is there a way the find out that "Cable" came from "Tele.lin" file?

Clear?
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

deegeecees

  • Guest
Re: Linetype from ?.lin file
« Reply #1 on: November 21, 2005, 12:43:06 PM »
Manually, or automated?

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Linetype from ?.lin file
« Reply #2 on: November 21, 2005, 12:52:05 PM »
Either way.
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

deegeecees

  • Guest
Re: Linetype from ?.lin file
« Reply #3 on: November 21, 2005, 01:01:55 PM »
You can open .lin files with an ASCII editor as in "Notepad" and do a search, or do a search for files with the proper criteria contained within the file.

Make sense?

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Linetype from ?.lin file
« Reply #4 on: November 21, 2005, 01:05:13 PM »
OK.  to clearify.

If i were to export all of the layers in a dwg to a txt file, with all of there info (Color, Linetype, on, thawed, etc.) How would I know what .lin file the linetype came from?

Is there a way to get this info? DXF codes?  Xdata?  Dict?
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

LE

  • Guest
Re: Linetype from ?.lin file
« Reply #5 on: November 21, 2005, 01:13:57 PM »
OK.  to clearify.

If i were to export all of the layers in a dwg to a txt file, with all of there info (Color, Linetype, on, thawed, etc.) How would I know what .lin file the linetype came from?

Is there a way to get this info? DXF codes?  Xdata?  Dict?

I do not think, it is going to be an easy task..... and mostly if those linetypes were defined/loaded from a custom .LIN file.

I have not tried any approach to do a similar task..... sorry.
« Last Edit: November 21, 2005, 01:23:35 PM by LE »

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Linetype from ?.lin file
« Reply #6 on: November 21, 2005, 01:32:34 PM »
I didn't think it would be easy if at all.  The more I read the more I don't think that it is possible.  Once the definition is loaded it becomes part of the dwg until it is purged.

Thanks Luis
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

LE

  • Guest
Re: Linetype from ?.lin file
« Reply #7 on: November 21, 2005, 01:37:46 PM »
I didn't think it would be easy if at all.  The more I read the more I don't think that it is possible.  Once the definition is loaded it becomes part of the dwg until it is purged.

Thanks Luis

 :-)

Yes.

I would simple give away the .LIN's, ask them to copy them in a support folder and let AutoCAD do the rest....

Sdoman

  • Guest
Re: Linetype from ?.lin file
« Reply #8 on: November 21, 2005, 05:58:21 PM »
You can however create a new *.lin file of linetypes defined inside a particular drawing.   Paul Turvil has a routine on his web page. 

http://www.turvill.com/t2/index.htm

If I remember correctly, he also has a routine to harvest hatch patterns too.

Joe Burke

  • Guest
Re: Linetype from ?.lin file
« Reply #9 on: November 22, 2005, 04:49:52 AM »
Tim,

Assuming the linetype in question came from some available .lin file and you
know what .lin files are available, something like this might work. Use the
following function to make a list of the linetypes in each .lin file. Then
search each list for the linetype name.

Uncomment the next to last line. If the linetype name is found in some list,
return (car lst).

If you don't know what .lin files are available, I suppose you could search the
support paths (getenv "ACAD") for .lin files.

Of course there's probably a number of which could go wrong. Such as duplicate
linetype names in various .lin files.

Code: [Select]
;; Based on code by Jason Piercey.
;; Argument: filename of linetype file such as "acad.lin"
;; which resides in a search path.
;; Returns: list of linetype names.
(defun GetLinetypes (filename / file line str lst)
  (setq file (open (findfile filename) "r"))
  (setq line (read-line File))
  (while line
    (if (wcmatch line "`**")
      (progn
        (setq str (substr (substr line 1 (vl-string-search "," line)) 2))
        (setq lst (cons str lst))
      )
    )
    (setq line (read-line file))
  )
  (close file)
  ;add filename
  ;(cons filename (reverse lst))
) ;end

TimSpangler

  • Water Moccasin
  • Posts: 2010
  • CAD Naked!!
Re: Linetype from ?.lin file
« Reply #10 on: November 22, 2005, 07:48:45 AM »
Thanks guys.

I will have to run a couple of test on the routine posted and see what kind of output i get.  Maybe I can cobble something up with it.

Thanks Again everyone.  It never seases to amaze me what comes out of this group.  You guys/ gals are amazing :mrgreen:
ACA 2015 - Windows 7 Pro
All Comments and Content by TimSpangler, Copyright © 2016

Joe Burke

  • Guest
Re: Linetype from ?.lin file
« Reply #11 on: November 22, 2005, 08:24:21 AM »
Tim,

Hope I wasn't vague about the next to last line of code. As originally designed, the function returns (reverse lst). Which doesn't include the filename.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Linetype from ?.lin file
« Reply #12 on: November 22, 2005, 09:00:18 AM »
How about this to start with?  <Correction> To add to Joe's suggestion.


Code: [Select]
(defun c:test()  (get-line-types))

;;  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 (append ltnames lineTypeList))
    )
  )

  (princ)
  lineTypeList
)
« Last Edit: November 22, 2005, 09:45:01 AM by CAB »
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.

Joe Burke

  • Guest
Re: Linetype from ?.lin file
« Reply #13 on: November 22, 2005, 09:32:24 AM »
Hmm... isn't that an an extension of what I suggested, rather than, "to start with"?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Linetype from ?.lin file
« Reply #14 on: November 22, 2005, 09:41:41 AM »
Quite so. Sorry i miss spoke. :oops:

I did take your suggestion and carry it to the next step.
What i meant was that is still not a finished routine.
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.

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.