59
327
268
后起之秀
使用道具 举报
29
781
430
中流砥柱
114
1万
; ** ============[ DwgLst.lsp ]============== **;; ** **;; ** FUNCTION: **;; ** Will Automatically Create a Drawing **;; ** List based on TitleBlock Attribute **;; ** Values. **;; ** **;; ** ======================================== **;; ** **;; ** SYNTAX: DWGLST **;; ** **;; ** AUTHOR: **;; ** Copyright (c) 2009, Lee McDonnell **;; ** Contact Lee Mac: CADTutor.net **;; ** TheSwamp.org **;; ** **;; ** ======================================== **;; ** **;; ** RESTRICTIONS: **;; ** Machine must be able to run **;; ** Microsoft Excel. **;; ** **;; ** ======================================== **;; ** **;; ** USAGE: **;; ** Attributes from every instance of a **;; ** Specified Block are Extracted to **;; ** Excel. **;; ** **;; ** An Excel file may be selected or **;; ** upon the user hitting Cancel at **;; ** the prompt, a new Excel file is **;; ** created. **;; ** **;; ** ======================================== **;; ** **;; ** VERSION: **;; ** 1.0 ~ 01.07.2009 **;; ** **;; ** ======================================== **;; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ;(defun c:DwgLst (/ *error* ss cAtt attlst oLst xlApp file xlshe UCells xlCells Col row blkName ValLst) (vl-load-com) (defun *error* (msg) (mapcar 'ObjRel (list xlApp xlShe UCells xlCells)) (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " msg " >>")) (princ "\n*Cancel*")) (princ)) (setq blkName "titleblock") (setq ValLst '("NAME" "DATE" "NUMBER")) (if (setq ss (ssget "_X" (list (cons 0 "INSERT") (cons 2 blkName) (cons 66 1)))) (progn (foreach Obj (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss))) (foreach Att (append (vlax-safearray->list (vlax-variant-value (vla-GetAttributes Obj))) (if (not (vl-catch-all-error-p (setq cAtt (vl-catch-all-apply 'vlax-safearray->list (list (vlax-variant-value (vla-getConstantAttributes Obj))))))) cAtt)) (if (vl-position (strcase (vla-get-TagString Att)) ValLst) (setq attlst (cons (cons (vla-get-TagString Att) (vla-get-TextString Att)) attlst)))) (setq olst (cons (vl-sort attlst (function (lambda (a b) (< (car a) (car b))))) olst) attlst nil)) (if (setq file (getfiled "Select Excel File" "" "xls" ) (progn (setq xlApp (vlax-get-or-create-object "Excel.Application") xlshe (vlax-get-property (vlax-get (vla-open (vlax-get xlApp "Workbooks") file) "Sheets") "Item" 1) Ucells (vlax-get xlshe "Usedrange")