Can someone please if did this correct. I took the Lisp that Mark Thomas wrote and added behind a batch run lisp. I got it to run, but it is not exporting layers. Here is the Lisp:
(defun c:BatchRun (/ UserFile UserDir FileList File#1 DwgName FileName )
(vl-load-com)
(setq UserFile (getfiled "Select a drawing within the directory to process" "" "dwg" 16 ) )
(setq UserDir (vl-filename-directory UserFile ) )
(setq FileList (vl-directory-files UserDir "*.dwg" 1 ) )
(setq File#1 (open "c:/BatchRun.scr" "w" ) )
(foreach DwgName FileList
(setq FileName (strcat "\"" UserDir "\\" DwgName "\"" ) )
(princ "open\n" File#1 )
(princ (strcat FileName "\n" ) File#1 )
(princ "(command \42._zoom\42 \42Extents\42 )\n" File#1 )
(princ)
)
(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:/Program Files/Brad's LISP/Layer Merging/"(getvar 'dwgname)".csv") "w"); suitable for Excel
)
(foreach l lylst
(write-line (strcat (car l) "," (cadr l) "," (last l)) fo)
)
(close fo)
)
)
(princ "_.close\n" File#1 )
(princ "N\n" File#1 ) ; do save
)
(close File#1 )
(command "._delay" "3000" ) ; wait ~3 sec to let file close
(command "._script" "C:/BatchRun.scr" )
(princ)
)
Thank you for all of your help,
Brad