Jump to content

Recommended Posts

Posted
On 1/11/2017 at 8:53 AM, Grrr said:

This should grip all blocks in the drawing, with the same name:

 

 

(defun C:test ( / blk SS nSS i e )
 (setvar 'errno 0)
 (while (/= 52 (getvar 'errno))
   (setq blk (car (entsel "\nSelect block to filter <exit>: ")))
   (cond 
     ((= 7 (getvar 'errno)) (princ) (setvar 'errno 0))
     ((and blk (/= "INSERT" (cdr (assoc 0 (entget blk))))) (princ))
     (blk 
       (setq blk (vla-get-EffectiveName (vlax-ename->vla-object blk)))
       (setq SS (ssget "_X" (list (cons 0 "INSERT"))))
       (setq nSS (ssadd))
       (repeat (setq i (sslength SS))
         (setq e (ssname SS (setq i (1- i))))
         (and (eq blk (vla-get-EffectiveName (vlax-ename->vla-object e)))
           (ssadd e nSS)
         )
       )
       (sssetfirst nil nSS)
       (setvar 'errno 52)
     )
   )
 )
 (princ)
)
 

 

I found this lsp and have been using it for a few years, great lsp. I used it today to delete a block from all layouts but when I switch from one layout to the next, the block still exists in all subsequent layouts. I want to delete our title block from all layouts, only 9 layouts, and purge it. It's the same identical block with the same name, any reason the above lsp wouldn't select them all?

 

Thanks

Posted (edited)
2 hours ago, demus72 said:

I found this lsp and have been using it for a few years, great lsp. I used it today to delete a block from all layouts but when I switch from one layout to the next, the block still exists in all subsequent layouts. I want to delete our title block from all layouts, only 9 layouts, and purge it. It's the same identical block with the same name, any reason the above lsp wouldn't select them all?

 

Thanks

Using this as a base try this code:

(defun c:foo (/ e n s)
  (if (and (setq e (car (entsel "\nPick block to delete: ")))
	   (setq n (assoc 2 (entget e)))
	   (setq s (ssget "_X" (list n)))
      )
    (foreach o (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex s)))
      (vl-catch-all-apply 'vla-delete (list o))
    )
  )
  (princ)
)

 

Edited by ronjonp

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