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