Jaap Marchal 发表于 2022-7-6 09:46:45

Forced delete (embedded) block

HELLO,
 
i`AM LOOKING FOR A LISP TO FORCE DELETE A (EMBEDDED)BLOCK FROM A DRAWING. SOMETHING LIKE LAYER DELETE.
 
THANKS
 
JAAP

ReMark 发表于 2022-7-6 09:50:23

Purge command with Block option?
 
Are the blocks named or anonymous?

Tharwat 发表于 2022-7-6 09:53:55

Check this out .....
 

(defun c:test (/ ss ss1 e Blks) ; Tharwat 17. 02. 2011 (if (and (setq ss (ssget "_+.:S" '((0 . "INSERT"))))      (setq ss1 (ssname ss 0))            (setq e (entget ss1))      )   (progn   (setq Blks (ssget "_x" (list '(0 . "INSERT")                      (cons 2 (cdr (assoc 2 e))))))          (command "_.Erase" Blks "")    )      (princ)   ) (princ) )
 
Tharwat

Jaap Marchal 发表于 2022-7-6 09:56:27

NO, IS NOT WORKING. WHEN I GIVE THE COMMAND "TEST". IT ASKS TO SELECT.-->
NOTHING IS DONE. AUTOCAD COMES BACK WITH: Command: TEST Unknown command "TEST".Press F1 for help.
 
 
 
WORKING WITH AUTOCAD ELECTRICAL 2010
 
JAAP

Tharwat 发表于 2022-7-6 10:02:00

On the contrary , It does the job quickly .
 
But with your Electrical version of Cad which is I have no idea if would except Lisp or not though .

Tiger 发表于 2022-7-6 10:05:03

 
Sounds like you haven't loaded the lisp correctly, see these instructions.
 
Also, please stop with the caps, being shout at is not fun.

BlackBox 发表于 2022-7-6 10:08:10

You may want to reconsider this line:
 
 
 
For fun, here's another option:
 

(defun c:FOO(/ *acadDoc* eName ss blockItem) (vl-load-com) (vla-startundomark   (setq *acadDoc*          (vla-get-activedocument (vlax-get-acad-object)))) (if (and (setq eName (car (entsel "\nSelect the Block You Wish to Delete: ")))          (setq ss (ssget "_x" (list '(0 . "INSERT") (assoc 2 (entget eName))))))   (progn   (vlax-for x(setq ss (vla-get-activeselectionset *acadDoc*))       (cond (blockItem)             ((setq blockItem (vla-item (vla-get-blocks *acadDoc*)                                        (vla-get-effectivename x)))))       (vla-delete x))   (vla-delete blockItem)   (vla-delete ss))) (vla-endundomark *acadDoc*) (princ))
 
Option #2 will also remove the block reference from the blocks collection.

alanjt 发表于 2022-7-6 10:09:52

Always cracks me up when I see that.

Tharwat 发表于 2022-7-6 10:13:46

Hello Renderman .
 
I guess that the following two lines are the same according to the use of them .
 

(cons 2 (cdr (assoc 2 e)))(assoc 2 e)
 
But for the situation of building the search filtering list , the cons might be better than(assoc 2 e) What you think ?

BlackBox 发表于 2022-7-6 10:16:22

 
You'll laugh, I always try to say it nicely... because I know there's one coming around the corner, pointed at me.
页: [1] 2
查看完整版本: Forced delete (embedded) block