Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Selecting/deleteing dtext

7 REPLIES 7
Reply
Message 1 of 8
bodhran
444 Views, 7 Replies

Selecting/deleteing dtext

 

Hi there,

 

Just wondering if anyone has script/routine to select and delete dtext from multiple drawings.

 

We're trying to remove particular instances of text originally placed into a drawings (about 2000 in total so far), the text is 4 characters in all cases but shares a layer with other text within the drawing which is making automating the selection a little tricky.

 

TIA,

 

B

7 REPLIES 7
Message 2 of 8
pbejse
in reply to: bodhran

what bout filtering by string value with an and condition?

 

Same textstyle? Textheight? color by layer? by entity?

Model and/or paper space?

Are these exclusively TEXT or some are MTEXT?

Part of an attribute?

 

Pardon for all the questions. it matters with filtering <string or otherwise>

 

Smiley Happy

 

 

 

 

 

 

 

Message 3 of 8
bodhran
in reply to: bodhran

Hi there,

 

It's not that easy to isolate the text strings, they are all dtext but share properties, style, layer etc with other dtext which we wish to retain, we were hoping for something that would use either wild cards (M1*) or a specifc number of characters to select the text entities.

 

B

Message 4 of 8
bodhran
in reply to: pbejse

 

 

Also we need something we can run over multiple drawings like a script!!

Message 5 of 8
pbejse
in reply to: bodhran

thats exactly why we're going to use  and function my friend,

 

sample:

 

(defun c:cmb ()
	(mapcar '(lambda (j)
                   	(if (eq (cdr (assoc 1 (entget j))) "BANANA")
                          	(vla-put-color (vlax-ename->vla-object j)  acBlue))
                          		)
                 (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "TEXT")))))))
          	(princ)
          )

 

This code will select all text with a string value of "BANANA"  and if by chance theres aother text with the same string but another layer, then:

 

(defun c:cmb ()
	(mapcar '(lambda (j)
                   	(if (and	
                          	(eq (cdr (assoc 1 (entget j))) "BANANA")
                          	(eq (cdr (assoc 8 (entget j))) "TEXT"))                          	(vla-put-color (vlax-ename->vla-object j)  acBlue))
                          		)
                 (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget '((0 . "TEXT")))))))
          	(princ)
          )

 

and so on ...

 

Running it thru script is fairly easy, tell me exactly what you need and we'll try and figure it out together

 

Smiley Happy

 

 

 Although this would do same

 

(ssget '((0 . "TEXT")(1 . "BANANA")(8 . "TEXT")))

 We are preparing for a routine that will execute exclusion depending on other factors

 

 

 

 

 

 

 

Message 6 of 8
Kent1Cooper
in reply to: bodhran


@bodhran wrote:

[earlier] ... the text is 4 characters in all cases ....

[later] ... they are all dtext but share properties, style, layer etc with other dtext which we wish to retain, we were hoping for something that would use either wild cards (M1*) or a specifc number of characters to select the text entities.

....


This will find all Text [or Mtext] entities of four characters beginning with M1 [see the wild-card options under (wcmatch) in the AutoLISP Reference]:

 

(ssget "X" '((1 . "M1??")))

 

If you think there might be other kinds of things than Text or Mtext that might have that kind of value in a 1-code entry, or if there might be Mtext entities that say the same thing that you would not want it to find, then add the Text filter [by the way, there's no such entity type as "dtext"]:

 

(ssget "X" '((0 . "TEXT") (1 . "M1??")))

Kent Cooper, AIA
Message 7 of 8
pbejse
in reply to: Kent1Cooper


@Kent1Cooper wrote:
 (ssget "X" '((0 . "TEXT") (1 . "M1??")))

Oh boy... never thought it would be that easy  Smiley Happy

 

I was thinking of something else entirely

 

simple like that Kent

 

Message 8 of 8
bodhran
in reply to: pbejse

Thanks guys!!

 

 

The ssget works perfectly!!

 

Thanks again!!

 

B

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost