通过选择交叉实体,返回选择集内包括文本实体。 Function CreateSelectionSetCrossingText(pt1 As Variant, pt2 As Variant) As AcadSelectionSet On Error Resume Next Dim sSet As AcadSelectionSet 'Dim SSet As AcadSelectionSet If Not IsNull(ThisDrawing.SelectionSets.Item("SelectEntity")) Then Set sSet = ThisDrawing.SelectionSets.Item("SelectEntity") sSet.Delete End If Set sSet = ThisDrawing.SelectionSets.Add("SelectEntity") Dim gpCode(0) As Integer Dim dataValue(0) As Variant gpCode(0) = 0 dataValue(0) = "Text" sSet.Select acSelectionSetCrossing, pt1, pt2, gpCode, dataValue Set CreateSelectionSetCrossingText = sSet End Function Sub lsls() Dim pt1, pt2 Dim sSet As AcadSelectionSet pt1 = ThisDrawing.Utility.GetPoint(, "Input First Point") pt2 = ThisDrawing.Utility.GetCorner(pt1, "Input First Point") Set sSet = CreateSelectionSetCrossingText(pt1, pt2) Dim objText As AcadText For ii = 0 To sSet.Count - 1 Set objText = sSet.Item(ii) Debug.Print objText.TextString Next ii End Sub
|