;;;writes every layer name out to a user selected .txt file > >(defun c:layer_write (/ cur_dir fil_name fil_tag chk) > > ;; Grab ACAD's current folder > (setq cur_dir (getvar "dwgprefix")) > > ;; Get a file name from the user > (setq fil_name (getfiled "Select file to write to" cur_dir "txt" 1)) > > ;; Open the file for writing > (setq fil_tag (open fil_name "w")) > > ;; Write the first line. Just get the first layer in the table > (write-line > (setq chk (cdr (assoc 2 (tblnext "LAYER" T)))) > fil_tag > ) ;_ end of write-line > > ;; Now loop through the layer table grabbing a layer name. > ;; Note: each call to tblnext will get the next layer. > (while chk > (setq chk (cdr (assoc 2 (tblnext "LAYER" nil)))) > > ;; If we got a layer, write. > ;; If tblnext returned nil we've got all the layers, > ;; so chk (now nil) will stop the loop. > (if chk > (write-line chk fil_tag) > ) ;_ end of if > > ) ;_ end of while > > ;; close the file > (close fil_tag) >) ;_ end of defun >