This exports all non-selected layers
(defun c:ExpLayToExcelReversed(/ *error* Table _openfile laylist all_layers i ss f fname)
(vl-load-com)
(defun *error* ( msg )
(if (not (member msg '("Function cancelled" "quit / exit abort")))
(princ (strcat "\nError: " msg))
)
(if f (close f))
(princ)
)
(defun _openfile (file / sh)
(setq sh (vlax-get-or-create-object "Shell.Application"))
(vlax-invoke-method sh 'open (findfile file))
(vlax-release-object sh)
)
(defun Table (s / d r)
(while (setq d (tblnext s (null d)))
(setq r (cons (cdr (assoc 2 d)) r))
)
)
(princ "\nSelect objects to extract layer names to Excel >")
(setq ss (ssget))
(cond
((and ss (setq fname (getfiled "Output file:" (getvar "dwgprefix") "csv" 3)))
(setq f (open fname "w") i -1)
(while (< (setq i (1+ i))(sslength ss))
(setq lay (cdr (assoc 8 (entget (ssname ss i)))))
(if (not (member lay laylist))(setq laylist (cons lay laylist)))
)
(setq all_layers (Table "layer"))
(foreach layer laylist
(if (member layer all_layers) (setq all_layers (vl-remove layer all_layers)))
)
(foreach layer all_layers
(write-line layer f)
)
(close f)
(_openfile fname)
)
)
(princ)
)
Miljenko Hatlak

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.