114
1万
中流砥柱
(defun c:CheckLayers (/ *error* ObjRelease DirDialog Get_Subs ObjectDBXDocument GetLayers Str-Make DBX DOCLST DWLST FILE FOLDER LAYER_LIST PATH SHELL) (vl-load-com) ;; Lee Mac ~ 15.01.10 (defun *error* (msg) (ObjRelease (list Shell dbx)) (and ofile (= (type ofile) 'FILE) (close ofile)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (defun ObjRelease (lst) (mapcar (function (lambda (x) (if (and (eq (type x) 'VLA-OBJECT) (not (vlax-object-released-p x))) (vl-catch-all-apply (function vlax-release-object) (list x))))) lst)) (defun DirDialog (msg dir flag / Shell Fold Path) ;; Lee Mac ~ 07.06.09 (setq Shell (vla-getInterfaceObject *acad "Shell.Application") Fold (vlax-invoke-method Shell 'BrowseForFolder (vla-get-HWND *acad) msg flag dir)) (vlax-release-object Shell) (if Fold (progn (setq Path (vlax-get-property (vlax-get-property Fold 'Self) 'Path)) (vlax-release-object Fold) (and (= "\" (substr Path (strlen Path))) (setq Path (substr Path 1 (1- (strlen Path))))))) Path) (defun Get_Subs (folder / file) ;; CAB (mapcar (function (lambda (x) (setq file (strcat folder "\" x)) (cons file (apply (function append) (get_subs file))))) (cddr (vl-directory-files folder nil -1)))) (defun ObjectDBXDocument (/ acVer) (vla-GetInterfaceObject *acad (if (< (setq acVer (atoi (getvar "ACADVER"))) 16) "ObjectDBX.AxDbDocument" (strcat "ObjectDBX.AxDbDocument." (itoa acVer))))) (defun GetLayerProperties (doc / lst) (vlax-for lay (vla-get-Layers doc) (setq lst (cons (mapcar (function (lambda (property) (vl-princ-to-string (vlax-get-property lay property)))) '(Name Color Linetype LineWeight)) lst))) (vl-sort lst (function (lambda (a b) (< (car a) (car b)))))) (defun Str-Make (lst del / Pad str x) (defun Pad (pStr pDel Len) (while (< (strlen pStr) Len) (setq pStr (strcat pStr pDel))) pStr) (setq str (Pad (car lst) (chr 32) 30)) (foreach x (cdr lst) (setq str (strcat Str Del (Pad x (chr 32) 30)))) str) (setq *acad (cond (*acad) ((vlax-get-acad-object))) *doc (cond (*doc ) ((vla-get-ActiveDocument *acad)))) (or *def* (setq *def* "Yes")) (if (and (setq Path (DirDialog "Select Directory" nil 0)) (vl-file-directory-p Path) (setq outfile (getfiled "Output File" "" "txt" 1))) (progn (initget "Yes No") (setq *def* (cond ((getkword (strcat "\nProcess SubDirectories? <" *def* "> : "))) (*def*))) (vlax-for doc (vla-get-Documents *acad) (setq DocLst (cons (cons (vla-get-FullName doc) doc) DocLst))) (foreach dwg (setq dwLst (apply (function append) (vl-remove 'nil (mapcar (function