chrisdvalentine Posted June 11, 2009 Posted June 11, 2009 Hello, I am trying to put together a lisp or tool that I could list all the layers in the current DWG and how many objects are on each layer, and send it to a text file. There are plenty of lisps out there that will allow listing all the layers, but that is it. Thank you, Quote
Shawndoe Posted June 11, 2009 Posted June 11, 2009 Hi, Here is one I created, it should work for you. It's a bit big to post, so it's here as an attachment. Have a good one. Shawndoe LayerList1-4.lsp Quote
Lee Mac Posted June 12, 2009 Posted June 12, 2009 Would this not be sufficient: (defun c:laylst (/ file ss lst) (vl-load-com) (if (setq file (getfiled "Output File" "" "txt" 9)) (progn (vlax-for lay (vla-get-layers (vla-get-ActiveDocument (vlax-get-acad-object))) (if (setq ss (ssget "_X" (list (cons 8 (vla-get-Name lay))))) (setq lst (cons (cons (vla-get-Name lay) (sslength ss)) lst)))) (setq file (open file "a")) (mapcar (function (lambda (x) (write-line (strcat (car x) (chr 32) (rtos (cdr x) 2 0)) file))) lst))) (princ)) Quote
CAB Posted June 12, 2009 Posted June 12, 2009 Slight variation: (defun c:laylst (/ layers file ss lst) (vl-load-com) (if (setq file (getfiled "Output File" "" "txt" 9)) (progn (vlax-for lay (vla-get-layers(vla-get-ActiveDocument(vlax-get-acad-object))) (setq layers (cons (vla-get-Name lay) layers)) ) (setq layers (acad_strlsort layers)) (mapcar (function (lambda(x) (if (setq ss (ssget "_X" (list (cons 8 x)))) (setq lst (cons (list x (itoa (sslength ss))) lst))))) layers) (if (and lst (setq file (open file "a"))) (progn (mapcar (function (lambda (x) (write-line (strcat (car x) " :--> " (cadr x)) file))) (reverse lst) ) (close file) (prompt (strcat "\nLayers reported: " (itoa (length lst)))) ) ) ) ) (princ) ) P.S. you didn't close your file. Quote
Lee Mac Posted June 12, 2009 Posted June 12, 2009 P.S. you didn't close your file. I always forget that dammit... Quote
CAB Posted June 12, 2009 Posted June 12, 2009 My wife leaves the back door open all the time, so you're in good company. Quote
chrisdvalentine Posted June 12, 2009 Author Posted June 12, 2009 Well thank you much guys. Essentially I was on the right track, my only problem was I was trying to right it in straight autolisp. The shortened VBA helped out allot, and I was able to make it work with what I had. Quote
Shawndoe Posted June 12, 2009 Posted June 12, 2009 My routine has much more coe then it needs to run single drawings, but it was actually written to run in batch runs as well as single drawings. it makes it much bigger then it needs to be. I originally wrote it as part of a drawing clean up job to look for layers that were misnamed or in some other way were non standard. Glad you found what you needed. Have a good one. Shawndoe Quote
wannabe Posted June 13, 2009 Posted June 13, 2009 My wife leaves the back door open all the time, so you're in good company. ahem!! Quote
Recommended Posts
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.