Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Mentor
engr_mondo
Posts: 206
Registered: ‎09-03-2010
Message 1 of 8 (275 Views)

Extract Layers...

275 Views, 7 Replies
03-05-2012 06:23 PM
How can I extract all layers in an open drawing to a notepad or txt file? TIA
Regards,

Mondo
Valued Mentor
gjrcmb
Posts: 326
Registered: ‎06-21-2011
Message 2 of 8 (266 Views)

Re: Extract Layers...

03-05-2012 06:49 PM in reply to: engr_mondo

Thanks to Lynn Allen on her recent video posting on a reminder on how to "Print a List of Your Layers" at http://www.cadalyst.com/video

Open Layer Manager, select All Layers (Ctrl-A), Copy all layers with Ctrl-C.  Open Notepad or actually Excel is better and Paste.

OR

Enter -Layer at the command prompt, type ?, then *, and copy layer listing from Text Screen.

*Expert Elite*
Kent1Cooper
Posts: 5,868
Registered: ‎09-13-2004
Message 3 of 8 (260 Views)

Re: Extract Layers...

03-05-2012 07:22 PM in reply to: engr_mondo

engr_mondo wrote:
How can I extract all layers in an open drawing to a notepad or txt file? TIA

If you just want the Layer names written out to a file, here's one way:

 

(defun C:LLTF (/ lay); = Layer List To File
  (setq LLF (open "X:/Your/File/Path/And/Filename.txt" "w"))
  (while (setq lay (tblnext "layer" (not lay)))
    (write-line (cdr (assoc 2 lay)) LLF)
  ); while
  (close LLF)
); defun

Kent Cooper
Valued Mentor
gjrcmb
Posts: 326
Registered: ‎06-21-2011
Message 4 of 8 (254 Views)

Re: Extract Layers...

03-05-2012 07:42 PM in reply to: engr_mondo

Oh, you want a lisp routine.  My oversight.  :smileyembarrassed:

Mentor
engr_mondo
Posts: 206
Registered: ‎09-03-2010
Message 5 of 8 (251 Views)

Re: Extract Layers...

03-05-2012 07:54 PM in reply to: gjrcmb
Copy-Paste thing doesn't work in 2011... Thanks to all!
Regards,

Mondo
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 6 of 8 (219 Views)

Re: Extract Layers...

03-06-2012 07:54 AM in reply to: engr_mondo

Mondo,

Try this lisp from my code library

Change to display properties as you need

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
*Expert Elite*
Kent1Cooper
Posts: 5,868
Registered: ‎09-13-2004
Message 7 of 8 (214 Views)

Re: Extract Layers...

03-06-2012 08:45 AM in reply to: Kent1Cooper

Kent1Cooper wrote:

....

If you just want the Layer names written out to a file, here's one way:

....


You can have it include more information about the Layer, if you want.  For example, to put the values for:

 

LayerName ColorNumber Linetype

 

on each Layer's line in the resulting text file, do this:

 

(defun C:LLTF (/ LLF lay); = Layer List To File
  (setq LLF (open "X:/Your/File/Path/And/Filename.txt" "w"))
  (while (setq lay (tblnext "layer" (not lay)))
    (write-line
      (strcat
        (cdr (assoc 2 lay)) " " ; name
        (itoa (cdr (assoc 62 lay))) " " ; color
        (cdr (assoc 6 lay)); linetype
      ); strcat
      LLF
    ); write-line
  ); while
  (close LLF)
); defun

Kent Cooper
Mentor
engr_mondo
Posts: 206
Registered: ‎09-03-2010
Message 8 of 8 (167 Views)

Re: Extract Layers...

03-11-2012 05:51 PM in reply to: Kent1Cooper
How to import back the exported file to AutoCAD and read modified items? TIA
Regards,

Mondo
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.