Relational Tests

AutoCAD AutoLISP & Visual LISP

 
Relational Tests
 
 
 

Unless otherwise specified, an equivalency is implied for each item in the filter-list. For numeric groups (integers, reals, points, and vectors), you can specify other relations by including a special -4 group code that specifies a relational operator. The value of a -4 group is a string indicating the test operator to be applied to the next group in the filter-list.

The following selects all circles with a radius (group code 40) greater than or equal to 2.0:

(ssget "X" '((0 . "CIRCLE") (-4 . ">=") (40 . 2.0)))

The possible relational operators are shown in the following table:

Relational operators for selection set filter lists

Operator

Description

"*"

Anything goes (always true)

"="

Equals

"!="

Not equal to

"/="

Not equal to

"<>"

Not equal to

"<"

Less than

"<="

Less than or equal to

">"

Greater than

">="

Greater than or equal to

"&"

Bitwise AND (integer groups only)

"&="

Bitwise masked equals (integer groups only)

The use of relational operators depends on the kind of group you are testing:

  • All relational operators except for the bitwise operators ("&" and "&=") are valid for both real- and integer-valued groups.
  • The bitwise operators "&" and "&=" are valid only for integer-valued groups. The bitwise AND, "&", is true if ((integer_group & filter) /= 0)—that is, if any of the bits set in the mask are also set in the integer group. The bitwise masked equals, "&=", is true if ((integer_group & filter) = filter)—that is, if all bits set in the mask are also set in the integer_group (other bits might be set in the integer_group but are not checked).
  • For point groups, the X, Y, and Z tests can be combined into a single string, with each operator separated by commas (for example, ">,>,*"). If an operator is omitted from the string (for example, "=,<>" leaves out the Z test), then the “anything goes” operator, "*", is assumed.
  • Direction vectors (group type 210) can be compared only with the operators "*", "=", and "!=" (or one of the equivalent “not equal” strings).
  • You cannot use the relational operators with string groups; use wild-card tests instead.