Jump to content

Text name filter


RepCad

Recommended Posts

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

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

Link to comment
Share on other sites

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

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

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