Jump to content
amir0914

Text name filter

Recommended Posts

amir0914

Hello every one,

I wrote this code to ssget all text :

(setq ss1 (ssget '((0 . "text,mtext"))))

 

Is it possible to ssget all texts except a specific text string in above code?  for example get all text except "Screw"

 

Edited by amir0914

Share this post


Link to post
Share on other sites
Tharwat

What do you mean by 'text name' ? is it text style or text string ?

  • Like 1

Share this post


Link to post
Share on other sites
amir0914

I mean is text string.

Share this post


Link to post
Share on other sites
Tharwat
(setq ss1 (ssget '((0 . "text,mtext")
		   (-4 . "<NOT")
		   (1 . "Screw")
		   (-4 . "NOT>")
		  )
	  )
)

 

  • Like 2

Share this post


Link to post
Share on other sites
amir0914
4 minutes ago, Tharwat said:

(setq ss1 (ssget '((0 . "text,mtext")
		   (-4 . "<NOT")
		   (1 . "Screw")
		   (-4 . "NOT>")
		  )
	  )
)

 

Thank you Tharwat, is it possible to do this with multiple text string name or list of string name? for example:

list = ("Screw","Hole","pin")

I mean ssget all texts except items of list

Share this post


Link to post
Share on other sites
Lee Mac

Hint: (-4 . "<OR") ... (-4 . "OR>")

  • Like 2

Share this post


Link to post
Share on other sites
Tharwat
11 hours ago, amir0914 said:

Thank you Tharwat, is it possible to do this with multiple text string name or list of string name? for example:

list = ("Screw","Hole","pin")

I mean ssget all texts except items of list

 

Example:

(setq lst '("Screw" "Hole" "pin"))

(setq ss1 (ssget
	    (append '((0 . "text,mtext") (-4 . "<NOT") (-4 . "<OR"))
		    (mapcar '(lambda (u) (cons 1 u)) lst)
		    '((-4 . "OR>") (-4 . "NOT>"))
	    )
	  )
)

 

  • Like 1

Share this post


Link to post
Share on other sites
amir0914

Many thanks for your consideration, I have another request, is it possible to select items of lst by ssget ?

 

Share this post


Link to post
Share on other sites
Tharwat
2 hours ago, amir0914 said:

Many thanks for your consideration, I have another request, is it possible to select items of lst by ssget ?

 

You're welcome anytime.

(setq lst '("Screw" "Hole" "pin"))

(setq ss1
       (ssget
	 (append
	   '((0 . "text,mtext"))
	   (list (cons 1 (apply 'strcat (mapcar '(lambda (u) (strcat u ",")) lst))))
	 )
     )
)

 

  • Like 1

Share this post


Link to post
Share on other sites
ronjonp
8 hours ago, Tharwat said:

 

Example:


(setq lst '("Screw" "Hole" "pin"))

(setq ss1 (ssget
	    (append '((0 . "text,mtext") (-4 . "<NOT") (-4 . "<OR"))
		    (mapcar '(lambda (u) (cons 1 u)) lst)
		    '((-4 . "OR>") (-4 . "NOT>"))
	    )
	  )
)

 

Quick test and this works too  (case sensitive of course).

(setq ss1 (ssget (append '((0 . "text,mtext"))
			 (mapcar '(lambda (u) (cons 1 (strcat "~" u))) '("Screw" "Hole" "pin"))
		 )
	  )
)

 

  • Like 1

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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