Jump to content

Recommended Posts

Posted

I have this routine (unknown to the author). Thank you for your help with the following change: Export the list of layers but only on a selection.

 

 

(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)
)

Posted
Here is a similar program with a few more options - also, note that you can select layers from the Layer Manager and copy them directly.
Posted

Lee, fantastic tool, as expected. Thank you for your statement. Already I kept. However, for this, I just want to extract the names of the layers contained in a selection, not the entire design.

Posted

Maybe something like this?

(defun c:layernames ( / f l s x )
   (if (and (setq s (ssget))
            (setq f (getfiled "Create File" "" "txt" 1))
       )
       (if (setq f (open f "w"))
           (progn
               (repeat (setq i (sslength s))
                   (or (member (setq x (cdr (assoc 8 (entget (ssname s (setq i (1- i))))))) l)
                       (and (write-line x f)
                            (setq l (cons x l))
                       )
                   )
               )
               (close f)
           )
           (princ "\nUnable to open file for writing.")
       )
   )
   (princ)
)

[untested]

Posted

Lee, that's exactly. Better, just even making out the list sorted alphabetically. Thank you! :)

Posted
Lee, that's exactly. Better, just even making out the list sorted alphabetically. Thank you! :)

 

You're welcome! - For an alphabetically sorted output, try the following:

(defun c:layernames ( / f l s x )
   (if (and (setq s (ssget))
            (setq f (getfiled "Create File" "" "txt" 1))
       )
       (if (setq f (open f "w"))
           (progn
               (repeat (setq i (sslength s))
                   (or (member (setq x (cdr (assoc 8 (entget (ssname s (setq i (1- i))))))) l)
                       (setq l (cons x l))
                   )
               )
               (foreach x (acad_strlsort l) (write-line x f))
               (close f)
           )
           (princ "\nUnable to open file for writing.")
       )
   )
   (princ)
)

  • Like 1
Posted

Lee, you're the best. But also generous. Thank you! :)

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...