Add Complexity to Your Filter List Conditions

AutoCAD ActiveX

 
Add Complexity to Your Filter List Conditions
 
 
 

When you specify multiple selection criteria, AutoCAD assumes the selected object must meet each criterion. But you can qualify your criteria in other ways. For numeric items, you can specify relational operations (for example, the radius of a circle must be greater than or equal to 5.0). And for all items, you can specify logical operations (for example, Text or Mtext).

Use a -4 DXF code to indicate a relational operator in your filter specification. Specify the operator as a string. The allowable 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)

Logical operators in filter lists are also indicated by a -4 group code, and the operator is a string, but the operators must be paired. The opening operator is preceded by a less-than symbol (<), and the closing operator is followed by a greater-than symbol (>). The following table lists the logical operators allowed in selection set filtering.

Logical 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>"

Select a circle whose radius is greater than or equal to 5.0

The following code specifies that the selected object must be a circle whose radius is greater than or equal to 5.0:

Sub Ch4_FilterRelational()
   Dim sstext As AcadSelectionSet
   Dim FilterType(2) As Integer
   Dim FilterData(2) As Variant
   Set sstext = ThisDrawing.SelectionSets.Add("SS5")
      
   FilterType(0) = 0
   FilterData(0) = "Circle"
   FilterType(1) = -4
   FilterData(1) = ">="
   FilterType(2) = 40
   FilterData(2) = 5#
      
   sstext.SelectOnScreen FilterType, FilterData
End Sub

Select either Text or Mtext

The following example specifies that either Text or Mtext objects can be selected:

Sub Ch4_FilterOrTest()
   Dim sstext As AcadSelectionSet
   Dim FilterType(3) As Integer
   Dim FilterData(3) As Variant
   Set sstext = ThisDrawing.SelectionSets.Add("SS6")
   FilterType(0) = -4
   FilterData(0) = "<or"
   FilterType(1) = 0
   FilterData(1) = "TEXT"
   FilterType(2) = 0
   FilterData(2) = "MTEXT"
   FilterType(3) = -4
   FilterData(3) = "or>"
      
   sstext.SelectOnScreen FilterType, FilterData
End Sub