Use Wild-Card Patterns in Selection Set Filter Criteria
 
 
 

Symbol names and strings in filter lists can include wild-card patterns.

The following table identifies the wild-card characters recognized by AutoCAD, and what each means in the context of a string:

Wild-card characters

Character

Definition

#โ€ƒ(pound)

Matches any single numeric digit

@โ€ƒ(at)

Matches any single alphabetic character

.โ€ƒ(period)

Matches any single nonalphanumeric character

*โ€ƒ(asterisk)

Matches any character sequence, including an empty one, and it can be used anywhere in the search pattern: at the beginning, middle, or end

?โ€ƒ(question mark)

Matches any single character

~โ€ƒ(tilde)

If it is the first character in the pattern, it matches anything except the pattern

[...]

Matches any one of the characters enclosed

[~...]

Matches any single character not enclosed

-โ€ƒ(hyphen)

Used inside brackets to specify a range for a single character

,โ€ƒ(comma)

Separates two patterns

`โ€ƒ(reverse quote)

Escapes special characters (reads next character literally)

Use a single quote (`) to indicate that a character is not a wildcard, but is to be taken literally. For example, to specify that only an anonymous block named โ€œ*U2โ€ be included in the selection set, use the following filter arguments:

FilterType(0) = 2
FilterData(0) = "`*U2"

Select Mtext where a specific word appears in the text

The following code defines the selection criteria as any Mtext in which โ€œTheโ€ appears in the text string. This example also demonstrates use of the SelectByPolygon selection method:

Sub Ch4_FilterPolygonWildcard()
   Dim sstext As AcadSelectionSet
   Dim FilterType(1) As Integer
   Dim FilterData(1) As Variant
   Dim pointsArray(0 To 11) As Double
   Dim mode As Integer
   mode = acSelectionSetWindowPolygon
   pointsArray(0) = -12#: pointsArray(1) = -7#: pointsArray(2) = 0
   pointsArray(3) = -12#: pointsArray(4) = 10#: pointsArray(5) = 0
   pointsArray(6) = 10#: pointsArray(7) = 10#: pointsArray(8) = 0
   pointsArray(9) = 10#: pointsArray(10) = -7#: pointsArray(11) = 0
   Set sstext = ThisDrawing.SelectionSets.Add("SS10")


   FilterType(0) = 0
   FilterData(0) = "MTEXT"
   FilterType(1) = 1
   FilterData(1) = "*The*"


   sstext.SelectByPolygon mode, pointsArray, FilterType, FilterData
End Sub