TheSwamp
CAD Forums => CAD General => Topic started by: M-dub on May 04, 2004, 12:56:16 PM
-
As the subject states, I'm looking for something that will either print out the layers in a drawing (Acad2000) or export them to an Excel spreadsheet or Word document. Anyone have any ideas? (Besides -layer and copying all that stuff to Word and all that garbage...I've got Freakin' TONS of layers in this one drawing in particular.)
Thanks a million!
Mike
-
why don't we write one real quick? I'll get it started.
-
that was quick Mark!!
creates a .csv file on the root of C named the same as the dwg.
example: Drawing1.csv
(defun c:layers2csv (/ get->layobj open->file lay lylst fo)
(vl-load-com)
(defun get->layrobj ()
(vla-get-Layers
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
)
(vlax-for lay (get->layrobj)
(setq lylst
(cons
(list
(vlax-get-property lay 'Name)
(itoa (vlax-get-property lay 'Color))
(vlax-get-property lay 'Linetype)
)
lylst
)
)
)
(if lylst
(progn
; remove layer '0' and reverse the list
(setq lylst (reverse (vl-remove (last lylst) lylst))
; sort the list
lylst (vl-sort lylst '(lambda (x y) (< (car x)(car y))))
fo (open (strcat "c:/"(getvar 'dwgname)".csv") "w"); suitable for Excel
)
(foreach l lylst
(write-line (strcat (car l) "," (cadr l) "," (last l)) fo)
)
(close fo)
)
)
(princ)
)
-
I am not worthy of your talents, Mark!
When are you gonna put that paypal thing up again? ;)
-
glad you like it :D
-
Go to your Sheet Manager tab, down to "Sheet Tools", then down to "Create Layer Report". Gives you a nice file that you can edit in WORD, and probably Excel.
-
(http://theswamp.org/lilly.pond/M-dub/bow.gif)
I'll have to try that one tomorrow Dent. Hopefully it works!
Thanks a lot!
Mike
-
Well, did it work ?
-
Call me an idiot, but I can't find 'Sheet Manager' so, No, I guess it didn't work. :(
I just have Acad 2000...pretty plain jane.
-
Dang!! Send me the drawing and I will send you a text file. A blank drawing with all of your layers loaded will do the trick.
-
Acutally Dent, I completely appreciate the offer, but the routine Mark provided me with worked like a charm.
Thanks a lot!
-
that was quick Mark!!
creates a .csv file on the root of C named the same as the dwg.
example: Drawing1.csv
(defun c:layers2csv (/ get->layobj open->file lay lylst fo)
(vl-load-com)
(defun get->layrobj ()
(vla-get-Layers
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
)
(vlax-for lay (get->layrobj)
(setq lylst
(cons
(list
(vlax-get-property lay 'Name)
(itoa (vlax-get-property lay 'Color))
(vlax-get-property lay 'Linetype)
)
lylst
)
)
)
(if lylst
(progn
; remove layer '0' and reverse the list
(setq lylst (reverse (vl-remove (last lylst) lylst))
; sort the list
lylst (vl-sort lylst '(lambda (x y) (< (car x)(car y))))
fo (open (strcat "c:/"(getvar 'dwgname)".csv") "w"); suitable for Excel
)
(foreach l lylst
(write-line (strcat (car l) "," (cadr l) "," (last l)) fo)
)
(close fo)
)
)
(princ)
)
Mark,
This cool, but where do the file go after your run the lisp?
-
I found it. Is there a way that the file can be sent to a folder that you want?
thank you,
Brad
-
Change this line
fo (open (strcat "c:/"(getvar 'dwgname)".csv") "w"); suitable for Excel
to the directory of your choosing (using forward slashes, of course). Like this:
fo (open (strcat "c:/this/is/my/favorite/folder/"(getvar 'dwgname)".csv") "w"); suitable for Excel
-
Go to your Sheet Manager tab, down to "Sheet Tools", then down to "Create Layer Report". Gives you a nice file that you can edit in WORD, and probably Excel.
I have 2005, i opened Sheet Set Manager, but I cant find what you are referring to.
-
Hi David,
I think Dent needs to update the 'version used note' his profile
-
Mark...
I would like to build upon this to have all the layer properties extracted to excel. I think it would be a great way to set-up layer scheme's, whats on, what's off, what color's, weights etc.
you have the list with vlax-
so where can I read more about this so I can understand what the missing items would be?
thanks,
Pieter
-
Thank you for all you help!
-
I hate to bring this back from the dead, but I have 2005 and this is not working for me. I can see all my layers layed out in the AutoCAD Text Window, but Im getting an error... Error: bad argument type: streamp nil... Can someone tell me how to fix this so it works or what Im doing wrong. Appreciate it!
-
there is one of mine...
;| ;;
LoFi Layer Output For Info ;;
;;
By: Andrea Andreetti |;
(defun c:LoFi ()
(setq lst2 nil)
iselected (ssget)
sscount (sslength iselected)
val1 (- sscount 1)
)
(repeat sscount
(setq a1 (entget (ssname iselected val1)))
(getinfo)
(setq lst1 (list (strcat layer "," itemcolor "," layercolor "," layerlock"," layerplot )))
(if (not (vl-position (car lst1) lst2))
(setq lst2 (append lst2 lst1))
)
(setq val1 (- val1 1))
);;end repeat
(printresult)
);;defun
;| ;;
GET INFO ;;
|;
(defun getinfo ()
(setq layer (cdr (assoc 8 a1));;layer
color (cdr (assoc 62 a1));;color
)
(if (not color)(setq itemcolor "ByLayer")(setq itemcolor (rtos color)))
(setq layercolor (rtos (cdr (assoc 62 (entget (tblobjname "layer" (cdr (assoc 8 (entget (cdar a1))))))))))
;;locked or not
(if (= 4 (logand 4 (cdr (assoc 70
(tblsearch "layer" (cdr (assoc 8 (entget (cdar a1)))))
))))
(setq layerlock "Yes")
(setq layerlock "No")
)
;;printable or not
(setq layerplot (rtos
(cdr (assoc 290 (entget (tblobjname "layer" (cdr (assoc 8 (entget (cdar a1))))))))
2)
)
(if (= layerplot "0") (setq layerplot "No")(setq layerplot "Yes"))
);;defun
;| ;;
PRINT RESULT ;;
|;
(defun printresult ()
(initget "Yes No")
(setq yon (getkword "Print in a File ?"))
(if (= (strcase yon) "YES")
(printfile)
(textprint)
)
)
;;;;;;;;;;;;;;;;;;;
(defun Printfile ()
(setq filew (open "c:\\LoSi_result.txt" "w"))
(princ
"
LAYER of SELECTED ITEM
______________________
")
(princ (strcat "\n\nFile: " (getvar "dwgname")) filew)
(princ (strcat "\n\nDate: " (menucmd "M=$(edtime,$(getvar,date),YYYY MON D H:MMam/pm)")) filew)
(princ "
__________________________________________________
Layer Color LOCK PRINT
Nname Item/Layer: Mode mode \n\n" filew)
(foreach n lst2
(getlst1)
(princ (strcat "\n" item1 spr1 item2 "/" item3 spr3 item4 spr4 item5 ) filew)
)
(close filew)
(startapp "notepad" "c:\\LoSi_result.txt")
(resetvar)
)
;;;;;;;;;;;;;;;;;;;
(defun textprint ()
(princ
"
LAYER of SELECTED ITEM
______________________
")
(princ (strcat "\n\nFile: " (getvar "dwgname")))
(princ (strcat "\n\nDate: " (menucmd "M=$(edtime,$(getvar,date),YYYY MON D H:MMam/pm)")))
(princ "
__________________________________________________
Layer Color LOCK PRINT
Nname Item/Layer: Mode mode \n\n" )
(foreach n lst2
(getlst1)
(princ (strcat "\n" item1 spr1 item2 "/" item3 spr3 item4 spr4 item5 ))
(textscr)
)
(resetvar))
;;;;;;;;;;;;;;;;;;
(defun getlst1 ()
(setq fLiL (car lst2))
(setq #s1 (vl-string-position (ascii ",") fLiL))
(setq item1 (substr fLiL 1 #s1))
(setq fLiL (substr fLiL (+ #s1 2)))
(setq spr# (- 20 #s1))
(setq spr1 (substr space (- 20 spr#)))
(setq #s2 (vl-string-position (ascii ",") fLiL))
(setq item2 (substr fLiL 1 #s2))
(setq fLiL (substr fLiL (+ #s2 2)))
(setq spr# (- 15 #s2))
(setq spr2 (substr space (- 15 spr#)))
(setq #s3 (vl-string-position (ascii ",") fLiL))
(setq item3 (substr fLiL 1 #s3))
(setq fLiL (substr fLiL (+ #s3 2)))
(setq spr# (- 15 #s3))
(setq spr3 (substr space (- 15 spr#)))
(setq #s4 (vl-string-position (ascii ",") fLiL))
(setq item4 (substr fLiL 1 #s4))
(setq fLiL (substr fLiL (+ #s4 2)))
(setq spr# (- 18 #s4))
(setq spr4 (substr space (- 18 spr#)))
(setq #s5 (vl-string-position (ascii "¯") fLiL))
(setq item5 (substr fLiL 1 #s5))
(setq lst2 (cdr lst2))
);;defun
;;;;;;;;;;;;;;;;;;
(defun resetvar ()
(setq VarLst '(#s1 #s2 #s3 #s4 #s5 lst1 lst2 item1 item2 item3 item4 item5 itemcolor
flil filew yon layerlock layerplot layer color sscount
iselected a1 val1))
(mapcar '(lambda (l) (set l nil)) VarLst)
(princ)
)
Maybe not good looking.....but it work. :kewl:
-
Mark...
I would like to build upon this to have all the layer properties extracted to excel. I think it would be a great way to set-up layer scheme's, whats on, what's off, what color's, weights etc.
you have the list with vlax-
so where can I read more about this so I can understand what the missing items would be?
thanks,
Pieter
(defun c:layers2csv (/ get->layobj open->file lay lylst fo)
(vl-load-com)
(defun get->layrobj ()
(vla-get-Layers
(vla-get-ActiveDocument
(vlax-get-acad-object)
)
)
)
(defun TrueFalse2Str (sym)
(if (= sym :vlax-true)
"True" "False")
)
(vlax-for lay (get->layrobj)
(setq lylst
(cons
(list
(vlax-get-property lay 'Name)
(itoa (vlax-get-property lay 'Color))
(vlax-get-property lay 'Linetype)
(strcat "ON="(TrueFalse2Str (vlax-get-property lay 'LayerOn)))
(strcat "FROZEN="(TrueFalse2Str (vlax-get-property lay 'Freeze)))
(strcat "LOCKED="(TrueFalse2Str (vlax-get-property lay 'Lock)))
)
lylst
)
)
)
;; ("XREFS" "7" "Continuous" "ON=True" "FROZEN=True" "LOCKED=False")
(if lylst
(progn
; remove layer '0' and reverse the list
(setq lylst (reverse (vl-remove (last lylst) lylst))
; sort the list
lylst (vl-sort lylst '(lambda (x y) (< (car x)(car y))))
fo (open (strcat "c:/"(getvar 'dwgname)".csv") "w"); suitable for Excel
)
(foreach l lylst
(write-line
(strcat (nth 0 l) "," ; name
(nth 1 l) "," ; color
(nth 2 l) "," ; linetype
(nth 3 l) "," ; On/Off
(nth 4 l) "," ; Frozen
(nth 5 l) ; Locked
)
fo)
)
(close fo)
)
)
(princ)
)