Jump to content

Recommended Posts

Posted (edited)

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
Posted

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

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

 

  • Like 2
Posted
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

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

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

 

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

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