BIGAL Posted November 14, 2013 Posted November 14, 2013 (edited) I created a dwg index lsp it has two parts reading the info out of the title blocks on seperate layouts then creating a table. I I run the two parts seperately it works when together stops working with an error at the point of table creation with an error. error: Exception occurred: 0xC0000005 (Access Violation) ; warning: unwind skipped on unknown exception ; 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) Edited November 14, 2013 by BIGAL Quote
Tharwat Posted November 14, 2013 Posted November 14, 2013 (foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS1 [color=red]0[/color] )) 'getattributes) The zero number must be replaced with the variable x Although you can rewrite the code with less lines of codes . Quote
pBe Posted November 14, 2013 Posted November 14, 2013 The zero number must be replaced with the variable x I'm guessing BIGAL wants to ensure that if there are more than one "DA1DRTXT" on a layout tab it will only process one block. @Bigal Anyhoo. yes it would be written some other way,one suggestion though, you dont need to step thru the layout tabs to generate the values for variable.list1 and list2 . BTW: cant seem to replicate the error message you posted when i ran the code. Quote
BIGAL Posted November 14, 2013 Author Posted November 14, 2013 (edited) Pbe the 0 just checks the first occurance of a block in the tab, I will though have a look at not opening each layout the original code amended the title block details in individual layouts so they were linked in updating. I have had a couple of screwy things lately with my Pc so I may cut and paste the whole code in case their is a hidden character in the text file. I will try it on another pc we have lots. Works fine on other PC so problem is my computer will run low level diagnostics on memory etc to see if I can find problem. Thanks for help will update code once done for anyone else to use. Edited November 15, 2013 by BIGAL Quote
BIGAL Posted November 15, 2013 Author Posted November 15, 2013 Changed a couple of things like not worrying opening layouts now it works on my pc I have no idea why. Just sorting the cell items out now have a couple of other questions but will post seperately as its to do with modifying the look of the table. Thanks for your help Quote
pBe Posted November 15, 2013 Posted November 15, 2013 Changed a couple of things like not worrying opening layouts now it works on my pc I have no idea why. Just sorting the cell items out now have a couple of other questions but will post seperately as its to do with modifying the look of the table. Thanks for your help Good for you, Holler if you need more help Bigal Cheers Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.