Logical Grouping of Filter Tests
 
 
 

You can also test groups by creating nested Boolean expressions that use the logical grouping operators shown in the following table:

Grouping operators for selection set filter lists

Starting

operator

Encloses

Ending

operator

"<AND"

One or more operands

"AND>"

"<OR"

One or more operands

"OR>"

"<XOR"

Two operands

"XOR>"

"<NOT"

One operand

"NOT>"

The grouping operators are specified by -4 groups, like the relational operators. They are paired and must be balanced correctly in the filter list or the ssget call will fail. An example of grouping operators in a filter list follows:

(ssget "X" 


 '(
	(-4 . "<OR")
	(-4 . "<AND")
		(0 . "CIRCLE")
		(40 . 1.0)
	(-4 . "AND>")
	(-4 . "<AND")
		(0 . "LINE")
		(8 . "ABC")
	(-4 . "AND>")
	(-4 . "OR>")
  )
)

This code selects all circles with a radius of 1.0 plus all lines on layer "ABC". The grouping operators are not case-sensitive; for example, you can specify "and>", "<or", instead of "AND>", "<OR".

Grouping operators are not allowed within the -3 group. Multiple application names specified in a -3 group use an implied AND operator. If you want to test for extended data using other grouping operators, specify separate -3 groups and group them as desired. To select all circles having extended data for either application "APP1" or "APP2" but not both, enter the following:

(ssget "X" 
 '((0 . "CIRCLE")
	(-4 . "<XOR")
	(-3 ("APP1"))
	(-3 ("APP2"))
	(-4 . "XOR>")
  )
)

You can simplify the coding of frequently used grouping operators by setting them equal to a symbol. The previous example could be rewritten as follows (notice that in this example you must explicitly quote each list):

(setq <xor '(-4 . "<XOR") 
	 xor> '(-4 . "XOR>") )
(ssget "X" 
  (list 
	'(0 . "CIRCLE")
	<xor
	'(-3 ("APP1"))
	'(-3 ("APP2"))
	xor>
  )
)

As you can see, this method may not be sensible for short pieces of code but can be beneficial in larger applications.