我创建了一个dwg索引lsp,它有两个部分,从单独布局的标题栏中读取信息,然后创建一个表。
我分别运行这两个部分,当一起在创建带有错误的表时停止处理错误时,它就会工作。
错误:发生异常:0xC0000005(访问冲突)
; 警告:未知异常时跳过了展开
- ; dwg index to a table
- ; by Alan H NOV 2013
- ;(defun AH:dwgindex (/ doc lay ans ans2 plotabs len ss1 tag2 tag3 list1 list2 clayout colwidth numcolumns numrows objtable rowheight )
- (defun AH:dwgindex (/ doc ans ans2 plotabs len ss1 tag2 tag3 )
- (vl-load-com)
- (setq curlayout (getvar "ctab"))
- (if (= clayout "Model")
- (progn
- (Alert "You need to be in a layout for this option")
- (exit)
- )
- )
- (setq doc (vla-get-activedocument (vlax-get-acad-object)))
- (setq curspace (vla-get-paperspace doc))
- (vlax-for lay (vla-get-Layouts doc)
- (setq plotabs (cons (vla-get-name lay) plotabs))
- )
- (setq pt1 (vlax-3d-point (getpoint "\nPick point for top left hand of table: ")))
- ;(setq pt1 (vlax-3d-point '(0 0 0)))
- ; for testing
- ; read values from title blocks
- (setq len (length plotabs))
- (setq x 0)
- (setq bname "DA1DRTXT")
- (setq tag2 "DRG_NO") ;attribute tag name
- (setq tag3 "WORKS_DESCRIPTION") ;attribute tag name
- ;(setq list1 ""
- ; list2 "")
- (repeat len
- (setq tabname (nth x plotabs))
- (if (/= tabname "Model")
- (progn
- (setvar "ctab" tabname)
- (setq ss1 (ssget "x" (list (cons 0 "INSERT") (cons 2 bname)(cons 410 tabname))))
- (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 0 )) 'getattributes)
- (if (= tag2 (strcase (vla-get-tagstring att)))
- (progn
- (setq ans (vla-get-textstring att))
- (if (/= ans NIL)
- (setq list1 (cons ans list1))
- )
- ); end progn
- ) ; end if
- (if (= tag3 (strcase (vla-get-tagstring att)))
- (progn
- (setq ans2 (vla-get-textstring att))
- (if (/= ans2 NIL)
- (setq list2 (cons ans2 list2))
- ) ; end if
- ) ; end progn
- ) ; end if
- ) ; end foreach
- ) ; end progn
- ) ; end if
- (setq x (+ x 1))
- ) ; end repeat
- (setvar "ctab" curlayout)
- (command "Zoom" "E")
- (command "regen")
- (alert "layouts done")
- ; now do table
- (setq numrows 5)
- (setq numcolumns 5)
- (setq rowheight 0.5)
- (setq colwidth 30)
- (setq objtable (vla-addtable curspace pt1 numrows numcolumns rowheight colwidth))
- (vla-settext objtable 0 0 "DRAWING REGISTER")
- (vla-settext objtable 1 0 "DRAWING NUMBER")
- (vla-settext objtable 1 1 "DRAWING TITLE")
- ;(SETQ ANS (NTH 0 LIST1))
- ;(vla-settext objtable 1 2 ANS)
- ;(vla-settext objtable 1 3 (NTH 0 LIST1))
- (vla-settext objtable 1 4 "E")
- (vla-settext objtable 2 0 "1") ; NUMBER
- (vla-settext objtable 3 0 "2")
- (vla-settext objtable 4 0 "3")
- (command "_zoom" "e")
- ); end table defun
- (AH:dwgindex)
- (princ)
|