Can I search for a block instance by it's anonymous name or handle?

Can I search for a block instance by it's anonymous name or handle?

cferriterF9DP9
Explorer Explorer
712 Views
8 Replies
Message 1 of 9

Can I search for a block instance by it's anonymous name or handle?

cferriterF9DP9
Explorer
Explorer

I have a drawing with around 1500 dynamic block instances, each with multiple attributes. I have exported the attribute data to a spreadsheet. In addition to the attribute data I entered, ACAD automatically exported a column for "Handle" and a column for "block name" which typically is it's anonymous name. I'm checking my work on the spreadsheet and need to go back to some blocks to update their attributes where I made an error but can't figure out how to search for the "handle" or anonymous "block name" with QSELECT, only it's effective name. Is there a way I can search and select a block instance based on it's "handle" or anonymous "block name"? 

0 Likes
Accepted solutions (1)
713 Views
8 Replies
Replies (8)
Message 2 of 9

John_WilliamsSYKJ2
Contributor
Contributor

I would recommend using the design center feature in cad to find all the blocks within a specific file. This will present a list for you to select your block.

0 Likes
Message 3 of 9

cferriterF9DP9
Explorer
Explorer

Unfortunately, the Design Center does not list every instance of the dynamic block. It's only listed once indicating that block is used in the file, but each of the 1500 instances with unique data are not listed separately. 

0 Likes
Message 4 of 9

Libbya
Mentor
Mentor

That depends on which program you are using.  For AutoCAD Architecture, if you select a dynamic block, right-click>select similar, then all insertions that share the same anonymous name are selected.  I believe that for base AutoCAD if you use select similar, then all of the dynamic blocks with the same block definition name (non-anonymous) are selected.  

0 Likes
Message 5 of 9

Sea-Haven
Mentor
Mentor

A few comments.

 

You can (ssget '((0 . "INSERT"))) then check for "effective name". 

You can use (ssget '((0 . "INSERT")(cons 5  handle)))

You can use (ssget '((0 . "INSERT")(cons 2  "**U23")))

0 Likes
Message 6 of 9

cferriterF9DP9
Explorer
Explorer

Thank you, can you please elaborate on how to use these commands? I had originally posted under the dynamic block forum but the post got moved here and I'm not familiar with what LISP is.

0 Likes
Message 7 of 9

paullimapa
Mentor
Mentor
Accepted solution

Try zmh.lsp which will prompt you for a handle. If block with attribute object is found will zoom into that location  to open the attribute editor highlighting block

; zmh given handle zooms to location of block with attribute, opens attribute editor & highlights block object 
; OP:
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/can-i-search-for-a-block-instance-by-it-s-anonymous-name-or/td-p/13146413/jump-to/first-unread-message
(defun c:zmh (/ ed en handle)
 (vl-load-com)
; (setq handle (cdr(assoc 5 (entget(car(entsel)))))) ; select object to retrieve handle
 (while(not handle)
  (if(setq handle (getstring"\nEnter Handle: "))
   (if(zerop(strlen handle))(setq handle nil)) ; chk for characters entered
  ) ; if
 ) ; while
 (if(setq en (handent handle)) ; locate entity
  (if
   (and
    (eq "INSERT" (cdr (assoc 0 (setq ed (entget en))))) ; chk if it's a Block insert
    (cdr (assoc 66 ed)) ; there are attributes
   )   
   (progn
    (setvar "ctab" (cdr (assoc 410 ed))) ; change to that drawing space
    (command "_.Zoom" "_O" en "") ; zoom up to that location
    (command "_.Eattedit" en) ; open attribute editor
    (sssetfirst nil (ssadd en)) ; highlight the object
   ) ; progn
   (princ (strcat "\nEntity Handle: [" handle "] is NOT a BLOCK with Attributes."))
  )
  (princ (strcat "\nEntity Handle: [" handle "] Not Located."))
 ) ; if
 (princ) ; clean exit
) ; defun

  


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 9

cferriterF9DP9
Explorer
Explorer

Thank you!

 

0 Likes
Message 9 of 9

paullimapa
Mentor
Mentor

You are welcome…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes