我的程序如下,为何总找不到文本?
Sub Example_Select() Dim ssetObj As AcadSelectionSet Dim ent As AcadEntity Dim Points Dim n As Integer ThisDrawing.SelectionSets.item(0).Delete Set ssetObj = ThisDrawing.SelectionSets.Add("SSET") Dim FilterType(0) As Integer Dim FilterData(0) As Variant
FilterType(0) = 0 FilterData(0) = "TEXT" Dim coor() As Double For Each ent In ThisDrawing.ModelSpace If ent.ObjectName = "AcDbPolyline" Then Points = ent.Coordinates n = UBound(Points) ReDim coor(n + (n + 1) / 2)
'因为画的线是2D的,改变坐标为3D For i = 0 To n Step 2 coor(i) = Points(i) coor(i + 1) = Points(i + 1) coor(i + 2) = 0 Next ssetObj.SelectByPolygon acSelectionSetWindowPolygon, coor, FilterType, FilterData If ssetObj.Count > 0 Then MsgBox "找到" & ssetObj.item(0).TextString Else MsgBox "没找到" End If End If Next ssetObj.Delete End Sub
|