Results 1 to 8 of 8

Thread: LISP to find and erase everything on a specific linetype

  1. #1
    100 Club
    Join Date
    2008-10
    Location
    London, UK
    Posts
    103
    Login to Give a bone
    0

    Default LISP to find and erase everything on a specific linetype

    Hi all
    I'm hoping someone will be able to help me out with this.

    I have a drawing which has a number of lines/polylines which I need to delete. These are located both inside of blocks and in the model space.

    Unfortunately the blocks are all named differently, (same items, just different names) and everything is generally on layer 0. As I'm sure you understand, this means I have to edit all the blocks individually to remove the unwanted lines.

    However, one saving grace is the items are all using a specific linetype.

    I can quick select to get rd of the ones in model space easily, but editing all the blocks is going to take ages.

    I've tried looking through a hatch delete lisp I have to see if I could change a few bits but as my lisp writing knowledge is very limited, I got lost very quickly.

    I've search google and the forum, but most linetype searches just return people trying to purge them.

    Any help would be greatly appreciated. I have a number of drawings I have to clean up and this could save me no end of time.

    Thanks in advance.
    Jonathan

  2. #2
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,508
    Login to Give a bone
    0

    Default Re: LISP to find and erase everything on a specific linetype

    Well here's a lisp that will erase all lines with the linetype "hidden2" (as an example)
    Note: this only works for lines that have hidden2 assigned to them vs ByLayer (assuming blocks are created on layer zero and have linetypes assigned to lines).
    Code:
    (defun c:foo (/ lns)
    (setq lns (ssget "x" ' ((0 . "line") (6 . "hidden2"))))
    (command ".erase" lns "")
    (princ)
    )
    Hope this helps..

  3. #3
    100 Club
    Join Date
    2008-10
    Location
    London, UK
    Posts
    103
    Login to Give a bone
    0

    Default Re: LISP to find and erase everything on a specific linetype

    Thanks Ted, that works.

    Would it be possible to adjust it so that it searches inside blocks without me having to open them?

    Even if I have to select the blocks myself that would be a massive time saver.

  4. #4
    100 Club
    Join Date
    2008-10
    Location
    London, UK
    Posts
    103
    Login to Give a bone
    0

    Default Re: LISP to find and erase everything on a specific linetype

    I've sped things up now by using the lisp and a macro.

    Adding the search blocks function would be amazing, but I've managed to save a large chunk of time already.

    Thanks again Ted
    Last edited by jonathan.a.pitt; 2017-06-22 at 02:35 PM.

  5. #5
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,508
    Login to Give a bone
    0

    Default Re: LISP to find and erase everything on a specific linetype

    Quote Originally Posted by jonathan.a.pitt View Post
    Thanks Ted, that works.

    Would it be possible to adjust it so that it searches inside blocks without me having to open them?

    Even if I have to select the blocks myself that would be a massive time saver.
    I think it's possible.. a bit over my head, I'll try to look to see if I find something.
    Maybe some other lisp guru has a suggestion.

  6. #6
    All AUGI, all the time
    Join Date
    2015-10
    Location
    Belgrade, Serbia, Europe
    Posts
    564
    Login to Give a bone
    0

    Default Re: LISP to find and erase everything on a specific linetype

    Maybe something like this, untested though...

    Code:
    (defun c:test ( / blks mch )
    
      (vl-load-com)
    
      (setq blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
      (vlax-for b blks
        (vlax-for o b
          (if (and (setq mch (cdr (assoc 6 (entget (vlax-vla-object->ename o))))) (wcmatch mch "hidden2,HIDDEN2"))
            (vla-delete o)
          )
        )
      )
      (princ)
    )
    Last edited by marko_ribar; 2017-06-23 at 05:12 AM.

  7. #7
    100 Club
    Join Date
    2008-10
    Location
    London, UK
    Posts
    103
    Login to Give a bone
    0

    Cool Re: LISP to find and erase everything on a specific linetype

    That worked like a charm, thank you so much Marko.

    Cheers guys, you have saved me so much time today.

    If all our work is done on a Friday we usually get to go home early, looks like that will happen today now. I'll raise a beer to you both later on.

  8. #8
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,508
    Login to Give a bone
    0

    Default Re: LISP to find and erase everything on a specific linetype

    Quote Originally Posted by marko_ribar View Post
    Maybe something like this, untested though...

    Code:
    (defun c:test ( / blks mch )
    
      (vl-load-com)
    
      (setq blks (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))))
      (vlax-for b blks
        (vlax-for o b
          (if (and (setq mch (cdr (assoc 6 (entget (vlax-vla-object->ename o))))) (wcmatch mch "hidden2,HIDDEN2"))
            (vla-delete o)
          )
        )
      )
      (princ)
    )
    Wow Marko, very nice.
    I knew someone out there with way more knowledge than me could help.

Similar Threads

  1. Lisp - Find specific text string replace style
    By NotACADNoob in forum AutoLISP
    Replies: 3
    Last Post: 2017-01-24, 02:15 AM
  2. Find Specific PViewport
    By bsardeson in forum VBA/COM Interop
    Replies: 0
    Last Post: 2010-11-09, 05:14 PM
  3. find text at specific location
    By rwbaker54 in forum VBA/COM Interop
    Replies: 5
    Last Post: 2007-10-24, 05:45 AM
  4. LISP ROUTINE TO ERASE ALL PAPERSPACE LAYOUTS
    By stephen.coff in forum AutoLISP
    Replies: 5
    Last Post: 2007-07-16, 11:57 AM

Posting Permissions

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