Jump to content

ssget returns nil


AbdRF

Recommended Posts

Hi,
I want to select text that is both on the layer "notes" and the color 3 using XOR operator.
 

(ssget '(
   (0 . "text")
   (-4 . "<xor") 
   (-4 . "<and") (8 . "notes") (62 . 3) (-4 . "and>") 
   (-4 . "xor>") 
))

But why I am getting "nil" as return value?
What is wrong with the above piece of code?

Thanks

Link to comment
Share on other sites

You don't need the XOR operator (i.e. exclusive OR) to obtain the desired result - you actually don't need any logical operators at all in this instance, as all of the elements of the filter list are applied with an implicit AND logic, and so the code can become:

(ssget '((0 . "TEXT") (8 . "notes") (62 . 3)))

 

Link to comment
Share on other sites

5 hours ago, Lee Mac said:

You don't need the XOR operator (i.e. exclusive OR) to obtain the desired result - you actually don't need any logical operators at all in this instance, as all of the elements of the filter list are applied with an implicit AND logic, and so the code can become:


(ssget '((0 . "TEXT") (8 . "notes") (62 . 3)))

 

 

I am learning how to use conditional operators with ssget function.I am aware that it can be done with above method.Just for learning purpose ,I wanted to try using XOR .But got nil with XOR method

 

Thanks

Edited by AbdRF
Link to comment
Share on other sites

1 hour ago, AbdRF said:

 

I am learning how to use conditional operators with ssget function.I am aware that it can be done with above method.Just for learning purpose ,I wanted to try using XOR .But got nil with XOR method

 

Thanks

 

XOR means that it matches any one of the conditions set, but not all of it. You'll have to use the AND operator as Lee stated if you'd want to use conditional operators:

  • Like 1
Link to comment
Share on other sites

22 hours ago, AbdRF said:

I am learning how to use conditional operators with ssget function.I am aware that it can be done with above method.Just for learning purpose ,I wanted to try using XOR .But got nil with XOR method

 

The XOR operator is not suited to your task, as you are specifically looking to select text objects with "layer 'notes' and the color 3" whereas, if you were to use the XOR operator in the following way:

(ssget '((0 . "TEXT") (-4 . "<XOR") (8 . "notes") (62 . 3) (-4 . "XOR>")))

The user would be able to select text on the "notes" layer or set to colour 3, but not both.

Link to comment
Share on other sites

On 4/27/2020 at 3:23 AM, Lee Mac said:

 

The XOR operator is not suited to your task, as you are specifically looking to select text objects with "layer 'notes' and the color 3" whereas, if you were to use the XOR operator in the following way:


(ssget '((0 . "TEXT") (-4 . "<XOR") (8 . "notes") (62 . 3) (-4 . "XOR>")))

The user would be able to select text on the "notes" layer or set to colour 3, but not both.


I got it @Lee Mac.Thanks for clearing it out.

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