DNK Posted February 18, 2010 Posted February 18, 2010 Is there a clean way of extracting block handles based upon block names? How about the handles of the attributes nested in the blocks? Will Data Extraction do it and I just can't find the right settings? Quote
DNK Posted February 19, 2010 Author Posted February 19, 2010 Tap, tap, tap....Is this thing on? Quote
ReMark Posted February 19, 2010 Posted February 19, 2010 Yes it is. Thanks for checking. Have you done an Internet search? Quote
DNK Posted February 19, 2010 Author Posted February 19, 2010 Yes it is. Thanks for checking. Have you done an Internet search? Of course. And I've gotten a mixture of ATTOUT, Data Extraction, a lot of stuff concerning Tables, but it's not quite what I'm looking for. I was more looking along the lines of getting the information in a drawing by drawing manner, of the data that is defined using the LIST command, but isolated to only blocks, based upon block name with a wildcard. It'd also be nice to be able to select only the data I need. Quote
Lee Mac Posted February 20, 2010 Posted February 20, 2010 Hey DNK, nice to see you in these parts Perhaps a custom LISP may accomplish this task - what would you extract to? Quote
DNK Posted February 20, 2010 Author Posted February 20, 2010 Hey DNK, nice to see you in these parts Perhaps a custom LISP may accomplish this task - what would you extract to? CSV maybe. Ideally, anything that I can manipulate in excel. Oooh. Maybe using ATTEXT? Quote
Lee Mac Posted February 20, 2010 Posted February 20, 2010 Is it just the attribute tags and relevant handles you want extracted, or block (insert) handles as well? Quote
DNK Posted February 20, 2010 Author Posted February 20, 2010 Is it just the attribute tags and relevant handles you want extracted, or block (insert) handles as well? Both actually. I'd like to list the block and the block handle (with some other basic properties like layer, name etc), then list out each attribute and it's respective handle. For the attributes, I'd like to list the tag (as the header) and then the value. Quote
Lee Mac Posted February 21, 2010 Posted February 21, 2010 Try this mate: (defun c:BlockOut (/ *error* lst2str FILE IATT IBLK INFO OFILE SS) (vl-load-com) (defun *error* (msg) (and ofile (close ofile)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (defun lst2str (lst del) (if (cdr lst) (strcat (car lst) del (lst2str (cdr lst) del)) (car lst))) (if (and (ssget '((0 . "INSERT"))) (setq file (getfiled "Output File" "" "csv" 1))) (progn (vlax-for obj (setq ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (setq iBlk (list (if (vlax-property-available-p obj 'EffectiveName) (vla-get-EffectiveName obj) (vla-get-Name obj)) (vla-get-Handle obj))) (if (eq :vlax-true (vla-get-HasAttributes obj)) (foreach att (vlax-invoke obj 'GetAttributes) (setq iAtt (cons (list (vla-get-TagString att) (vla-get-Handle att) (vla-get-TextString att)) iAtt)))) (setq Info (cons (cons iBlk iAtt) Info) iBlk nil iAtt nil)) (vla-delete ss) (setq ofile (open file "w")) (foreach b Info (write-line (lst2str (car b) ",") ofile) (foreach a (cdr b) (write-line (lst2str a ",") ofile)) (write-line "" ofile)) (setq ofile (close ofile)))) (princ)) 1 Quote
DNK Posted February 24, 2010 Author Posted February 24, 2010 Did my code work for you DNK? I haven't had a chance to test it. I've been busy with billable hours, so no real down time. I'll let you know when I have a moment. Thanks for checking. Quote
DNK Posted February 25, 2010 Author Posted February 25, 2010 Did my code work for you DNK? Yes, it did. Thanks for working that out. FWIW, we use handles as pointers to and from a MySQL database. Quote
Lee Mac Posted February 25, 2010 Posted February 25, 2010 Yes, it did. Thanks for working that out. FWIW, we use handles as pointers to and from a MySQL database. Excellent, happy to help 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.