Visual LISP, AutoLISP and General Customization

Reply
*Expert Elite*
pbejse
Posts: 2,406
Registered: ‎11-24-2009
Message 11 of 11 (281 Views)

Re: Lisp routine to delete blocks

06-21-2012 08:13 AM in reply to: jjorovi

a quick mod

 

(defun c:deleteblock  (/ *error* msge effnme ent entl setl e)
      (vl-load-com)
      (alert
            "warning! - this command deletes all occurences of block selected")
      (defun *error*  (msge)
            (princ "error: ")
            (setq msge (princ "\nfunction cancelled"))
            (terpri))
      (setq effnme (lambda (x)
                         (vla-get-effectivename
                               (if (eq (type x) 'ENAME)
                                     (vlax-ename->vla-object x)
                                     x))))
      (princ "\nselect block to delete: ")
      (if (setq ent (ssget "_:smileyfrustrated:" '((0 . "INSERT"))))
            (progn
                  (setq entl (effnme (ssname ent 0)))
                  (ssget "x" (list (cons 2 (strcat entl ",`*U*"))))
                  (vlax-for
                         itm  (vla-get-ActiveSelectionSet
                                    (vla-get-ActiveDocument
                                          (vlax-get-acad-object)))
                        (if (eq (effnme itm) entl)
                              (vl-catch-all-apply
                                    'vla-delete
                                    (list itm))))
                  (princ (strcat "\nall blocks named "
                                 entl
                                 " have now been deleted")))
            (princ "\nNo Block Selected:"))

      (princ)
      )

 

HTH

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community