解决方案 | cad选择集找出包含特定字符串的多行文本

发布时间 2024-01-01 20:18:37作者: IssacNew

代码如下:

 1 # 选择文本中出现特定单词的多行文字
 2 # 下面的代码将选择条件定义为文本字符串中出现“The”的任意选项。此示例还演示了选择方法的用法:MtextSelectByPolygon
 3 
 4 Sub Ch4_FilterPolygonWildcard()
 5   Dim sstext As AcadSelectionSet
 6   Dim FilterType(1) As Integer
 7   Dim FilterData(1) As Variant
 8   Dim pointsArray(0 To 11) As Double
 9   Dim mode As Integer
10   mode = acSelectionSetWindowPolygon
11   pointsArray(0) = -12#: pointsArray(1) = -7#: pointsArray(2) = 0
12   pointsArray(3) = -12#: pointsArray(4) = 10#: pointsArray(5) = 0
13   pointsArray(6) = 10#: pointsArray(7) = 10#: pointsArray(8) = 0
14   pointsArray(9) = 10#: pointsArray(10) = -7#: pointsArray(11) = 0
15   Set sstext = ThisDrawing.SelectionSets.Add("SS10")
16 
17   FilterType(0) = 0
18   FilterData(0) = "MTEXT"
19   FilterType(1) = 1
20   FilterData(1) = "*The*"
21 
22   sstext.SelectByPolygon mode, pointsArray, FilterType, FilterData
23 End Sub

 

参考资料:

https://www.cadn.net.cn/portal.php?mod=view&aid=8496