Export layers list (only a sel
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))))(setqoecho (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(setqlyr (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)(setqon? "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)) 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. 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. 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))
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)) Lee, you're the best. But also generous. Thank you! ........
页:
[1]