Results 1 to 5 of 5

Thread: Select blocks with no entities except attributes

  1. #1
    100 Club mikehaff's Avatar
    Join Date
    2010-10
    Posts
    196
    0 Did you find this post helpful? Yes

    Default Select blocks with no entities except attributes

    I have drawings that have blocks that consist of nothing but attributes. Apparently, in the past, someone would just change the attribute values to null instead of erasing the block. So, in some cases, I have several blocks in a drawing that are invisible in unpurgeable. Also, I don't already know the names of said blocks. I need to write a routine to erase these. That's simple enough, but I'm stumped on how to create a selection set of blocks that contain only attributes and those attributes are all null. Can anyone help?

  2. #2
    AUGI Addict
    Join Date
    2006-12
    Posts
    1,732
    0 Did you find this post helpful? Yes

    Default Re: Select blocks with no entities except attributes

    Work through the BLOCK table (or Blocks collection). That will give you the defining elements of each block ie. whether it has anything other than attributes, and by extension the blocks you need to search for. From there you can call (ssget ...) or iterate through the various layout collections to pick them off.

    FYI: don't forget to check inside other block definitions. These types of blocks get *everywhere* from inserting drawings into blank drawings, WBLOCKING, and other drawing "fixes". Wouldn't happen to be similar in name to AF, AO, AI, AF-FLOW, etc. would they?
    If you are going to fly by the seat of your pants, expect friction burns.
    Some say beauty is in the eye of the Beholder... perhaps so, but I've only seen the disintegration beam.
    Everyone else being wrong is not the same thing as being right.

  3. #3
    All AUGI, all the time pbejse's Avatar
    Join Date
    2010-10
    Posts
    501
    0 Did you find this post helpful? Yes

    Default Re: Select blocks with no entities except attributes

    Quote Originally Posted by mikehaff View Post
    ....I have several blocks in a drawing that are invisible in unpurgeable. .
    I guess what you meant by invisible is "not seen" on drawing screen and not "invisible mode" attribute definition.

    Quote Originally Posted by mikehaff View Post
    ...but I'm stumped on how to create a selection set of blocks that contain only attributes and those attributes are all null.
    So the condition is IF and ONLY IF the block is all Attribute and the inserted block is "invisible" [meaning attributes with null value]

    Try this

    Code:
    (defun c:Aab (/ blocks ss bnlsy e att bn) ;<--- Attribute And Blank
      (setq	Blocks (vla-get-blocks
    		 (vla-get-ActiveDocument (vlax-get-acad-object))
    	       )
      )
      (if (setq bnlst nil
    	    ss	  (ssget "_X" '((0 . "INSERT") (66 . 1)))
          )
        (repeat (setq i (sslength ss))
          (setq e	(vlax-ename->vla-object (ssname ss (setq i (1- i))))
    	    att	(vlax-invoke e 'Getattributes)
          )
          (and (cond
    	     ((member (setq bn (vla-get-effectivename e)) bnlst))
    	     ((= (vla-get-count
    		   (vla-item blocks
    			     (setq bn (vla-get-effectivename e))
    		   )
    		 )
    		 (length att)
    	      )
    	      (setq bnlst (Cons bn bnlst))
    	     )
    	   )
    	   (vl-every '(lambda (a)
    			(eq (vla-get-textstring a) "")
    		      )
    		     att
    	   )
    	   (vla-delete e)
          )
        )
      )
      (princ)
    )
    (vl-load-com)
    Quote Originally Posted by dgorsman View Post
    FYI: don't forget to check inside other block definitions. These types of blocks get *everywhere* from inserting drawings into blank drawings,
    I guess we can incorporate that option on the routine as well.

  4. #4
    100 Club mikehaff's Avatar
    Join Date
    2010-10
    Posts
    196
    0 Did you find this post helpful? Yes

    Default Re: Select blocks with no entities except attributes

    Thank you pbjese. That works swimmingly!

  5. #5
    All AUGI, all the time pbejse's Avatar
    Join Date
    2010-10
    Posts
    501
    0 Did you find this post helpful? Yes

    Default Re: Select blocks with no entities except attributes

    Quote Originally Posted by mikehaff View Post
    Thank you pbjese. That works swimmingly!
    Great, Happy to help.

Similar Threads

  1. Select entities by color of an exploded block
    By cadconcepts in forum AutoLISP
    Replies: 12
    Last Post: 2011-06-27, 03:02 PM
  2. Select entities off the screen
    By bweir in forum AutoLISP
    Replies: 5
    Last Post: 2007-04-20, 09:14 PM
  3. Can't select entities
    By jpaulsen in forum AutoCAD General
    Replies: 6
    Last Post: 2007-04-19, 03:20 PM
  4. Replies: 18
    Last Post: 2005-10-28, 12:18 AM
  5. Select entities without touching them
    By acadwishlist in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2005-10-05, 12:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •