Manuel_Kunde Posted August 24, 2021 Posted August 24, 2021 What command can I use to find a block by its name in my drawing and then delete it? Quote
yxl030 Posted August 24, 2021 Posted August 24, 2021 To See if this is what you want http://www.lee-mac.com/deleteblocks.html 1 Quote
Manuel_Kunde Posted August 25, 2021 Author Posted August 25, 2021 On 8/24/2021 at 12:01 PM, yxl030 said: To See if this is what you want http://www.lee-mac.com/deleteblocks.html I'm looking for something like that. But I can't get it work right now. In some drawings I have a block that I want to delete if it is there (via lisp). ;;; Purge named block ;;; Example: (ax:purge-block (vla-get-activedocument (vlax-get-acad-object)) "testblock") ;;; Argument: doc {document} ;;; name {a block name} ;;; Return values: T if successful, nil if not successful (defun c:deletetestblock () (defun ax:purge-block (doc name) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-delete (list (vl-catch-all-apply 'vla-item (list (vla-get-blocks doc) name) ) ) ) ) nil ; name cannot be purged or doesn't exist T ; name purged ) ) (ax:purge-block (vla-get-activedocument (vlax-get-acad-object)) "testblock") ) Quote
mhupp Posted August 25, 2021 Posted August 25, 2021 8 minutes ago, Manuel_Kunde said: I'm looking for something like that. But I can't get it work right now. Load the lisp. type delblocks it will allow you to pick a block. if you choose the name option it will open a menu to pick the names out of a list. if your drawing has alot of blocks use the filter at the bottom to narrow the list of blocks that contain whats in the filter. in your lisp im guessing you just want to automatically purge it when you open a drawing? add a vl-load-com to that bad boy and you should be good. (ax:purge-block (vla-get-activedocument (vlax-get-acad-object)) "BLOCKNAME") 1 Quote
Manuel_Kunde Posted August 25, 2021 Author Posted August 25, 2021 31 minutes ago, mhupp said: Load the lisp. type delblocks it will allow you to pick a block. if you choose the name option it will open a menu to pick the names out of a list. if your drawing has alot of blocks use the filter at the bottom to narrow the list of blocks that contain whats in the filter. in your lisp im guessing you just want to automatically purge it when you open a drawing? add a vl-load-com to that bad boy and you should be good. (ax:purge-block (vla-get-activedocument (vlax-get-acad-object)) "BLOCKNAME") Thanks for your quick reply, but I don't get it. I want to delete the block without user input, so when I write the command "deletetestblock", the "testblock" should be deleted. (defun ax:purge-block (doc name) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-delete (list (vl-catch-all-apply 'vla-item (list (vla-get-blocks doc) name) ) ) ) ) nil ; name cannot be purged or doesn't exist T ; name purged ) ) (defun c:deletetestblock () (vl-load-com) (ax:purge-block (vla-get-activedocument (vlax-get-acad-object)) "testblock") ) Quote
mhupp Posted August 25, 2021 Posted August 25, 2021 (edited) Load lee's and use the following (defun C:deletetestblock () (setq doc (vla-get-activedocument (vlax-get-acad-object))) (LM:deleteblocks doc '("testblock")) ) Edited August 25, 2021 by mhupp 1 Quote
Manuel_Kunde Posted August 25, 2021 Author Posted August 25, 2021 5 minutes ago, mhupp said: just load lee's and use the following Thank's, this works for me. Quote
Recommended Posts
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.