Using ssget to select text that contain specific string

Using ssget to select text that contain specific string

S_S_SS
Advocate Advocate
1,401 Views
7 Replies
Message 1 of 8

Using ssget to select text that contain specific string

S_S_SS
Advocate
Advocate

Hello every one 
i need to select all the text or mtext in the DWG that in the layer name "Tube Length" and the text or mtext contain string "Tube,L=" 
i've made the code but it gives me error 

  (ssget "X"
                  '( '(0 . "TEXT,MTEXT")
                    '(8 . "tube length")
                    '(1 . "*Tube,L=*")
                    );List
                   );ssget

can someone tell what's the error here ??

thanks in advance 
0 Likes
Accepted solutions (2)
1,402 Views
7 Replies
Replies (7)
Message 2 of 8

paullimapa
Mentor
Mentor

You don’t need to prefix the list with an apostrophe. This is only necessary if you include cons statements. Try

 

 

(ssget "X"
    '( (0 . "TEXT,MTEXT")
       (8 . "tube length")
       (1 . "*Tube,L=*")
     );List
 );ssget

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 8

ec-cad
Collaborator
Collaborator
Accepted solution

Looks like it may be tripping up on the text content '(1 . "*Tube,L=*") - in that it contains a "," which is

normally a way to seperate text strings to seek.

Also, you may be getting an error if you don't have a symbol to return the selection set to..

Try: (setq SS (ssget "X" (list (cons 0 "*TEXT")(cons 1 "*Tube*"))))

For me, it returns a selection set of those items.

ECCAD

 

0 Likes
Message 4 of 8

S_S_SS
Advocate
Advocate

I'm sorry but it still nil 

0 Likes
Message 5 of 8

S_S_SS
Advocate
Advocate
thanks very much the error is about the symbols
0 Likes
Message 6 of 8

paullimapa
Mentor
Mentor

As @ec-cad reply the comma may be throwing it off. But at least you’re no longer getting an error. Let’s try something more simple first and also match the caps in your layer name 

(ssget "X"
    '( (0 . "TEXT,MTEXT")
       (8 . "Tube Length")
       (1 . "*Tube*")
     );List
 );ssget

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

@ec-cad wrote:

Looks like it may be tripping up on the text content '(1 . "*Tube,L=*") - in that it contains a "," which is

normally a way to seperate text strings to seek. ....


You don't need to restrict your filtering to a shorter sub-string just to avoid the comma separator problem.  You can go for the longer string including the comma by adding a reverse-apostrophe take-the-next-character-literally trigger [I think it's referred to as an "escape" character for the special characters in wildcard strings]:

(wcmatch "XYZ Tube,L=34.56" "*Tube`,L=*")

returns T, because the comma is taken for itself, not as a separator of allowable strings.  So include:

(1 . "*Tube`,L=*")

in your (ssget) filter list.

Kent Cooper, AIA
Message 8 of 8

S_S_SS
Advocate
Advocate

thanks for this it's great ...

0 Likes