Niv Posted October 20, 2021 Share Posted October 20, 2021 (edited) On 7/26/2011 at 8:42 AM, irneb said: You're welcome. Here's a mod which should handle nested blocks as well: (defun c:DelText (/ ss eo blst bcol b) ;; Select the block references - all inserts (if (ssget "_:L" '((0 . "INSERT"))) (progn (setq ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object)))) (vlax-for eo ss (if (not (vl-position (vla-get-EffectiveName eo) blst)) ;Only add it if it's not already added (setq blst (cons (vla-get-EffectiveName eo) blst)) ) ) (vla-Delete ss) ) ) ;; Step through block definitions and erase the text within (setq bcol (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))) ss 0 ) (while (< ss (length blst)) (setq b (vla-Item bcol (nth ss blst)) ;Get block definition ss (1+ ss) ) (if (and ;Omit layouts & xrefs dependent blocks (eq :vlax-false (vla-get-isxref b)) (eq :vlax-false (vla-get-islayout b)) ) (vlax-for eo b ;Step through all items inside block definition (cond ((wcmatch (vla-get-ObjectName eo) "AcDbText,AcDbMText") ;Check if it's a text/mtext (vla-Delete eo) ) ((and (wcmatch (vla-get-ObjectName eo) "AcDbBlockReference") ;If it's a block, and (not (vl-position (vla-get-EffectiveName eo) blst)) ;Not already added to list to be changed ) (setq blst (append blst (list (vla-get-EffectiveName eo)))) ;Append its name to end of list ) ) ) ) ) (vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports) (princ) ) Hi , Is there a way to have only specific text chosen and deleted? My nested block has two text objects. One object has BASE in text and other one has different contents. I tried below command to search for text "BASE" , but I got too many arguments error ((wcmatch (vla-get-ObjectName eo) "AcDbText,AcDbMText" "*BASE*") Reg, NM Edited October 20, 2021 by Niv Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 20, 2021 Share Posted October 20, 2021 You'll need to change this: ((wcmatch (vla-get-ObjectName eo) "AcDbText,AcDbMText") To: ((and (wcmatch (vla-get-ObjectName eo) "AcDbText,AcDbMText") (wcmatch (strcase (vla-get-textstring eo)) "*BASE*") ) 1 Quote Link to comment Share on other sites More sharing options...
JJRicaldi Posted August 15, 2022 Share Posted August 15, 2022 Hi, Is there a way to select only the text with more than a certain number of bowels and then delete it? My blocks have a code and the block's name on the exact text. I only want to delete the title and leave the code. JJ, TY Quote Link to comment Share on other sites More sharing options...
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.