+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Senior Member stevesfr's Avatar
    Computer Details
    stevesfr's Computer Details
    Operating System:
    Vista <ugh>
    Computer:
    HP Pavilion
    Monitor:
    Dell Trinitron
    Using
    AutoCAD 2008
    Join Date
    Jan 2009
    Location
    Central Illinois, USA
    Posts
    270

    Angry Erase all insertions of one block name

    Registered forum members do not see this ad.

    Greetings
    How to write short lisp to erase all insertions of one unique block?
    or how to do same from command line?
    i.e.
    (command "._erase" <blockname> "")
    but this doesn't work.... somewhere there must be a place for a dotted pair?
    TIA
    Steve

  2. #2
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,953

    Default

    1. "Select" block
    2. "Right-Click", Select "Select Similar"
    3. Press "Delete"
    "Potential has a shelf life." - Margaret Atwood

  3. #3
    Senior Member stevesfr's Avatar
    Computer Details
    stevesfr's Computer Details
    Operating System:
    Vista <ugh>
    Computer:
    HP Pavilion
    Monitor:
    Dell Trinitron
    Using
    AutoCAD 2008
    Join Date
    Jan 2009
    Location
    Central Illinois, USA
    Posts
    270

    Default

    Quote Originally Posted by RenderMan View Post
    1. "Select" block
    2. "Right-Click", Select "Select Similar"
    3. Press "Delete"
    thanks, but if I knew what to do after Command " da da " etc. I could glue it into a lisp. I intend for lisp program to automatically erase the hardwired block name I put in.
    Thanks tho for reply
    Steve

  4. #4
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,953

    Default

    Separately, the ERASE command is expecting a selection set.

    Code:
    (defun c:FOO  (/ ss)
      (if (setq ss (ssget ":S:E:L" '((0 . "INSERT"))))
        (command
          "._erase"
          (ssget "_x"
                 (list '(0 . "INSERT")
                       (cons 2 (cdr (assoc 2 (entget (ssname ss 0)))))
                       (cons 410 (getvar 'ctab))))
          "")
        (prompt "\n** Nothing selected ** "))
      (princ))
    "Potential has a shelf life." - Margaret Atwood

  5. #5
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,953

    Default

    Quote Originally Posted by stevesfr View Post
    thanks, but if I knew what to do after Command " da da " etc. I could glue it into a lisp. I intend for lisp program to automatically erase the hardwired block name I put in.
    Thanks tho for reply
    Steve
    Aha - Had I known...

    Code:
    (defun c:FOO  (/ ss)
      (if (setq ss (ssget "_x"
                          (list '(0 . "INSERT")
                                '(2 . <BlockName>)
                                (cons 410 (getvar 'ctab)))))
        (command "._erase" ss "")
        (prompt "\n** No blocks found ** "))
      (princ))
    "Potential has a shelf life." - Margaret Atwood

  6. #6
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,744

    Default

    Quickly written:

    Code:
    (defun c:DelBlock ( / blk ent inc obj sel )
        (while
            (not
                (or
                    (eq "" (setq blk (getstring t "\nSpecify Block Name: ")))
                    (tblsearch "BLOCK" blk)
                )
            )
            (princ "\nBlock not Found.")
        )
        (if
            (and
                (not (eq "" blk))
                (setq sel (ssget "_X" (list '(0 . "INSERT") (cons 2 (strcat "`*U*," blk)))))
            )
            (repeat (setq inc (sslength sel))
                (setq ent (ssname sel (setq inc (1- inc)))
                      obj (vlax-ename->vla-object ent)
                )
                (if
                    (or
                        (and
                            (vlax-property-available-p obj 'effectivename)
                            (eq
                                (strcase blk)
                                (strcase (vla-get-effectivename obj)))
                        )
                        (eq
                            (strcase blk)
                            (strcase (vla-get-name obj))
                        )
                    )
                    (entdel ent)
                )
            )
        )
        (princ)
    )
    (vl-load-com) (princ)
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  7. #7
    Senior Member stevesfr's Avatar
    Computer Details
    stevesfr's Computer Details
    Operating System:
    Vista <ugh>
    Computer:
    HP Pavilion
    Monitor:
    Dell Trinitron
    Using
    AutoCAD 2008
    Join Date
    Jan 2009
    Location
    Central Illinois, USA
    Posts
    270

    Default

    Thank you Lee and RM... I now have the tools to complete my task !!! guys here are the best of the NET !!!
    cheers and beers around !!
    Steve

  8. #8
    Forum Deity BlackBox's Avatar
    Using
    Civil 3D 2011
    Join Date
    Nov 2009
    Posts
    3,953

    Default

    Quote Originally Posted by stevesfr View Post
    cheers and beers around !!
    I cheers and beers. LoL
    "Potential has a shelf life." - Margaret Atwood

  9. #9
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,744

    Default

    Registered forum members do not see this ad.

    You're welcome Steve
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

Similar Threads

  1. Parallel Insertions
    By Greenbuoy in forum AutoCAD Beginners' Area
    Replies: 6
    Last Post: 14th Feb 2011, 08:13 am
  2. Break/Erase Pline inside of block
    By cabltv1 in forum AutoLISP, Visual LISP & DCL
    Replies: 84
    Last Post: 29th Apr 2010, 08:35 am
  3. Again some help wanted with using Dynamic Block insertions
    By MarcoW in forum AutoCAD Drawing Management & Output
    Replies: 0
    Last Post: 14th Mar 2010, 05:09 pm
  4. Multiple block insertions at co ordinates
    By MisterJingles in forum AutoCAD Beginners' Area
    Replies: 18
    Last Post: 8th Oct 2009, 03:47 pm
  5. portion of block will not erase
    By gortex in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 9th Apr 2006, 02:22 pm

Bookmarks

Posting Permissions

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