Jump to content

Delete all text from block lisp


ibanez_222

Recommended Posts

 

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 by Niv
Link to comment
Share on other sites

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*")
 )

 

  • Thanks 1
Link to comment
Share on other sites

  • 9 months later...

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

Link to comment
Share on other sites

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