Jump to content

Layer list with the description column


teknomatika

Recommended Posts

I have this routine (unknown to the author), which lets you export to a text file the list of existing layers in a drawing. It works fine, but I wanted a version that could include one column for the description of each layer.

Thank you in advance for your possible help.

 

(defun c:LL2T ( / oecho clrlst dwgnm fn fh lyr lyrlst)
(defun chkbit (bit_val num)
(not (zerop (logand bit_val num)))
)
(setq
oecho (getvar "cmdecho")
clrlst (list
(cons 1 "RED")
(cons 2 "YELLOW")
(cons 3 "GREEN")
(cons 4 "CYAN")
(cons 5 "BLUE")
(cons 6 "MAGENTA")
(cons 7 "WHITE")
)
dwgnm (getvar "dwgname")
)
(setvar "cmdecho" 0)
(setq fn (getfiled " File name: " (strcat dwgnm ".LS") "LS" (+ 1 2))
)
(while (setq lyr (tblnext "layer" (not lyr)))
(setq lyrlst (cons (cdr (assoc 2 lyr)) lyrlst))
)
(setq lyrlst (acad_strlsort lyrlst))
(princ "\nWriting layer data to file...")
(setq fh (open fn "w"))
(princ (strcat dwgnm ".DWG\n") fh)
(foreach x lyrlst
(setq
lyr (tblsearch "layer" x)
lyrname (cdr (assoc 2 lyr))
lyrclr (cdr (assoc 62 lyr))
lyrlt (cdr (assoc 6 lyr))
frzn? (chkbit 1 (cdr (assoc 70 lyr)))
lokd? (chkbit 4 (cdr (assoc 70 lyr)))
)
(if (minusp lyrclr)
(setq
on? "OFF"
lyrclr (abs lyrclr)
)
(setq on? "ON")
)
(if (assoc lyrclr clrlst)
(setq lyrclr (cdr (assoc lyrclr clrlst)))
)
(if frzn?
(setq frzn? "FROZEN")
(setq frzn? "THAWED")
)
(if lokd?
(setq lokd? "LOCKED")
(setq lokd? "UNLOCKED")
)
(princ lyrname fh)
;;(princ "," fh)
;;(princ lyrclr fh)
;;(princ "," fh)
;;(princ lyrlt fh)
;;(princ "," fh)
;;(princ on? fh)
;;(princ "," fh)
;;(princ frzn? fh)
;;(princ "," fh)
;;(princ lokd? fh)
(princ "\n" fh)
)
(princ "done.")
(close fh)
(setvar "cmdecho" oecho)
(princ)
)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...