Results 1 to 5 of 5

Thread: Select blocks with no entities except attributes

  1. #1
    I could stop if I wanted to
    Join Date
    2015-10
    Posts
    215
    Login to Give a bone
    0

    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
    2015-12
    Posts
    2,095
    Login to Give a bone
    0

    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?

  3. #3
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    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
    I could stop if I wanted to
    Join Date
    2015-10
    Posts
    215
    Login to Give a bone
    0

    Default Re: Select blocks with no entities except attributes

    Thank you pbjese. That works swimmingly!

  5. #5
    All AUGI, all the time
    Join Date
    2010-10
    Posts
    535
    Login to Give a bone
    0

    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 the last N entities created in a lisp routine.
    By jpcadconsulting347236 in forum AutoLISP
    Replies: 7
    Last Post: 2015-06-23, 04:36 PM
  2. Select entities by color of an exploded block
    By cadconcepts in forum AutoLISP
    Replies: 12
    Last Post: 2011-06-27, 03:02 PM
  3. Select entities off the screen
    By bweir in forum AutoLISP
    Replies: 5
    Last Post: 2007-04-20, 09:14 PM
  4. Can't select entities
    By jpaulsen in forum AutoCAD General
    Replies: 6
    Last Post: 2007-04-19, 03:20 PM
  5. Select entities without touching them
    By autocad.wishlist1734 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
  •