Jump to content

Recommended Posts

Posted

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" "")

but this doesn't work.... somewhere there must be a place for a dotted pair?

TIA

Steve

Posted

  1. "Select" block
  2. "Right-Click", Select "Select Similar"
  3. Press "Delete"

Posted
  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

Posted

Separately, the ERASE command is expecting a selection set. ;)

 

(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))

Posted
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...

 

(defun c:FOO  (/ ss)
 (if (setq ss (ssget "_x"
                     (list '(0 . "INSERT")
                           '(2 . [color=red]<BlockName>[/color])
                           (cons 410 (getvar 'ctab)))))
   (command "._erase" ss "")
   (prompt "\n** No blocks found ** "))
 (princ))

Posted

Quickly written:

 

(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)

Posted

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

Posted

cheers and beers around !!

 

I :heart: cheers and beers. LoL

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...