Jump to content

Recommended Posts

Posted

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?

Posted

Yes it is. Thanks for checking.

 

Have you done an Internet search?

Posted
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.

Posted

Hey DNK, nice to see you in these parts :)

 

Perhaps a custom LISP may accomplish this task - what would you extract to?

Posted
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? :idea:

Posted

Is it just the attribute tags and relevant handles you want extracted, or block (insert) handles as well?

Posted
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.

Posted

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))


       

       
       
       

  • Like 1
Posted
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. :)

Posted
Did my code work for you DNK?

 

 

Yes, it did. Thanks for working that out.:thumbsup:

 

 

FWIW, we use handles as pointers to and from a MySQL database.

Posted
Yes, it did. Thanks for working that out.:thumbsup:

 

 

FWIW, we use handles as pointers to and from a MySQL database.

 

Excellent, happy to help :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...