Jump to content

Delete Text objects throughout drawing consisting of a specific string.


pateksan

Recommended Posts

Hello,

I've had a great response to my first post here so I hope I will find some understanding this time too.

My drawing has 66 layouts created from an incorrect template, and each has lots of Text objects I need to delete.

As before, I have very limited time for troubleshooting, so I'm hoping someone can help out.

Based on several other threads, which all had some aspect similar to what I need, I came to this one-liner:

(entdel (car (sssetfirst nil (ssget "_X" '((1 . "TQ00E"))))))

which produces

error : bad argument type <NIL> ; expected ENTITYNAME at [entdel]

I am hoping this is because sssetfirst returns multiple entities and entdel needs one at a time - if that is the case, I know what's wrong, and just don't have the time to learn how to make a loop.

If it helps, the Text objects contain specific, known strings like TQ00E above - there is nothing else in an individual Text entity.

I am resigned to replacing all these texts with spaces using Find and replace, but that's bad practice so I'm hoping someone can correct my code. Naturally I don't mind if I get dirty, non-optimal multi-line code.

Thanks in advance!

Link to comment
Share on other sites

probably something like
 (if (setq ss (ssget "x" '((1 . "TQ00E"))))(command "erase" ss "")) 

What a beauty. Have a good weekend!
Link to comment
Share on other sites

What a beauty. Have a good weekend!

 

 

Your welcome. If you change "TQ00E" to "TQ00E," (with the comma) you delete empty texts at the same time.

 

 

Have a good weekend too.

 

 

gr. Rlx

Link to comment
Share on other sites

What a beauty. Have a good weekend!
Ok, I got a bit carried away, this code only works on the current layout, and I was hoping I could remove all copies of the particular Text object on all layouts. Is this easily doable?
Link to comment
Share on other sites

Ok, I got a bit carried away, this code only works on the current layout, and I was hoping I could remove all copies of the particular Text object on all layouts. Is this easily doable?

 

(vl-load-com)
(defun del-txt ()
 (if (ssget "_x" '((0 . "text")(1 . "TQ00E")))
   (vlax-for n (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))
     (vla-delete n)))(princ))

 

gr. Rlx

Link to comment
Share on other sites

Hi, I needed to pass the drawing on so I Replaced All the relevant strings with a space. I know it's not pretty but it's not my fault I inherited a drawing with a questionable template. It's just a shame Bricscad Quick Select only works for one layout at a time. I will definitely look into this VL business though as it keeps coming up when I google my LISP problems. Thank you once again.

Link to comment
Share on other sites

pateksan here is an example of stepping through layout tabs, normally I check for /= "model" also

(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lay (vla-get-Layouts doc)
(setvar 'ctab (vla-get-name lay) )
(alert (strcat "Tab has changed to " (vla-get-name lay)))
)

Link to comment
Share on other sites

@pateksan:

Quick Select is indeed restricted to the current space. This perfectly logical as the same applies to editing commands.

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