See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Remove / Delete Block from multiple Layouts at the same time

  1. #1
    Member
    Join Date
    2001-04
    Posts
    6
    Login to Give a bone
    0

    Default Remove / Delete Block from multiple Layouts at the same time

    I have a situation where I have a drawing that has 76 layouts. Each layout has the same block in it. I am looking for a way to remove the block from the drawing completely. The block contains some attributes. I have tried to convert the block to an xref, and then detaching the xref. I get an error that says something about multiple references detected. If anyone has a good suggestion, it would be tremendously helpful. Thank you in advance for your help.

  2. #2
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: Remove / Delete Block from multiple Layouts at the same time

    a lisp routine sounds like it is what you would want, I have not checked this one, but you might want to give it a try

    Code:
    (defun c:deleteblock (/ ss)
    (setq ss (ssget "_X" '((-4 . "<and")
    	 (0 . "insert")
    	 (2 . "blockname")
    	 (-4 . "and>")
    	 )
    	)
    )
    (command "erase" ss "")
    (command "purge" "b" "blockname" "N")
    )
    inside the quotes everywhere it is blockname, replace it with the name of the block you want to erase, then it should erase them all and purge it as well. As I said, I have not tested it, hopefully it will work, if not I will try to revise it, or maybe someone else could.

  3. #3
    Member
    Join Date
    2001-04
    Posts
    6
    Login to Give a bone
    0

    Default Re: Remove / Delete Block from multiple Layouts at the same time

    Thanks for the lisp routine. Unfortunately, it only deleted the block in the layout that was current. All of the other layouts still had the block attached. Obviously, I could have removed the block individually by this point. But it is now a mission that I would like to accomplish. This is not the first time I have wanted to do something like this. If you could modify the routine so it runs in every layout that would be awesome. Increased productivity is my forte, programming is not. Thanks again!

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,127
    Login to Give a bone
    0

    Default Re: Remove / Delete Block from multiple Layouts at the same time

    The following is not completely tested. But you can try it and it may be what you are looking for.
    Code:
    (defun C:DELETEBLOCK (/ SS BNAME FILTER SSLEN ENT)
      (while (/= (type BNAME) 'STR)
        (cond ((= BNAME NIL)
    	   (setq BNAME (entsel "\nSelect block to remove from the drawing: "))
    	  )
    	  ((= (length BNAME) 2)
    	   (setq BNAME (entget (car BNAME)))
    	  )
    	  ((= (cdr (assoc 0 BNAME)) "INSERT")
    	   (setq BNAME (cdr (assoc 2 BNAME)))
    	  )
    	  ((/= (cdr (assoc 0 BNAME)) "INSERT")
    	   (prompt "\nEntity selected is not a block.")
    	   (setq BNAME (entsel "\nSelect block to remove from the drawing: "))
    	  )
        )
      )
      (setq	FILTER (list (cons 0 "INSERT")
    		     (cons 2 BNAME)
    	       )
    	SS     (ssget "_X" FILTER)
      )
      (if SS
        (progn
          (vl-load-com)
          (repeat (setq SSLEN (sslength SS))
    	(vlax-invoke-method (vlax-ename->vla-object (ssname ss (setq SSLEN (1- SSLEN)))) 'Delete)
          )
        )
      )
      (command "purge" "b" bname "N")
    )
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,127
    Login to Give a bone
    0

    Default Re: Remove / Delete Block from multiple Layouts at the same time

    I tried to use plain lisp but the entdel would only delete from the model space and the last viewed layout. So, I had to use a little visual lisp. Let me know if there is any problems with it.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  6. #6
    Member
    Join Date
    2001-04
    Posts
    6
    Login to Give a bone
    0

    Default Re: Remove / Delete Block from multiple Layouts at the same time

    Sorry, I sent you an e-mail thanking you for the lisp. Maybe it did not send. I am not really sure how to respond in this forum, should I use the reply button or should I use the send e-mail to option. Either way, the routine worked perfectly. I'm not sure which one you used with your test, but I had no trouble with mine. It removed all instances of the block including the ones out in all layout tabs. Thanks again!

  7. #7
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,127
    Login to Give a bone
    1

    Default Re: Remove / Delete Block from multiple Layouts at the same time

    Quote Originally Posted by autocad.13572
    Sorry, I sent you an e-mail thanking you for the lisp. Maybe it did not send. I am not really sure how to respond in this forum, should I use the reply button or should I use the send e-mail to option. Either way, the routine worked perfectly. I'm not sure which one you used with your test, but I had no trouble with mine. It removed all instances of the block including the ones out in all layout tabs. Thanks again!
    I did get your email. I chose to respond in the public forums. This allows others to find the best solution for their problems.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  8. #8
    The Silent Type Mike.Perry's Avatar
    Join Date
    2000-11
    Posts
    13,656
    Login to Give a bone
    0

    Default Re: Remove / Delete Block from multiple Layouts at the same time

    Quote Originally Posted by autocad.13572
    <SNIP> Maybe it did not send. I am not really sure how to respond in this forum, should I use the reply button or should I use the send e-mail to option. <SNIP>
    Hi

    Hopefully you will find some of the following information useful...

    * AUGI Forum Guidelines

    * How to Forum article ( Opens PDF document ).

    * Threads found in the "Forum Tips & Tricks" forum ( please note, this forum has restricted posting privileges - "regular" members can not post in there ).

    * Most Frequently Asked Questions

    * User Maintenance

    * General Forum Usage

    * Reading and Posting Messages

    Have a good one, Mike

  9. #9
    Member
    Join Date
    2001-04
    Posts
    6
    Login to Give a bone
    0

    Default Re: Remove / Delete Block from multiple Layouts at the same time

    Hey, thanks for the info, I be up to speed in no time. Thanks again!

  10. #10
    I could stop if I wanted to RenataP's Avatar
    Join Date
    2004-02
    Location
    Flint, Michigan, USA
    Posts
    370
    Login to Give a bone
    0

    Default Re: Remove / Delete Block from multiple Layouts at the same time

    Quote Originally Posted by ccowgill
    a lisp routine sounds like it is what you would want, I have not checked this one, but you might want to give it a try

    Code:
    (defun c:deleteblock (/ ss)
    (setq ss (ssget "_X" '((-4 . "<and")
    	 (0 . "insert")
    	 (2 . "blockname")
    	 (-4 . "and>")
    	 )
    	)
    )
    (command "erase" ss "")
    (command "purge" "b" "blockname" "N")
    )
    inside the quotes everywhere it is blockname, replace it with the name of the block you want to erase, then it should erase them all and purge it as well. As I said, I have not tested it, hopefully it will work, if not I will try to revise it, or maybe someone else could.
    Thank you very much for posting this.
    Came in this morning and had to delete one block in 200 drawings and forgot that they are not all in the same location. So I needed lsp. This was very helpful to do a search and up came lots of help.
    Made my day!!!

Page 1 of 2 12 LastLast

Similar Threads

  1. Insert a block on multiple layouts
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2012-11-14, 01:03 AM
  2. Replies: 2
    Last Post: 2012-11-13, 02:38 PM
  3. 2010: Explode a block in multiple layouts
    By frankflipsen1191073 in forum AutoCAD General
    Replies: 2
    Last Post: 2012-09-24, 05:17 AM
  4. Same block multiple layouts
    By chris.petty330967 in forum API Wish List
    Replies: 0
    Last Post: 2011-11-07, 06:56 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
  •