1. Public Type TextWithPnt
    2. Index As Long
    3. TextObj As AcadText
    4. PntIntX As Double
    5. PntIntY As Double
    6. PntLeftX As Double
    7. PntMidX As Double
    8. PntRigX As Double
    9. End Type
    10. Public OrgTexts() As TextWithPnt
    11. Public Function CreateSSet(Optional SS As String = "mjtd") As AcadSelectionSet
    12. On Error Resume Next
    13. ThisDrawing.SelectionSets(SS).Delete
    14. Set CreateSSet = ThisDrawing.SelectionSets.Add(SS)
    15. End Function
    16. Public Sub BuildFilter(typeArray, dataArray, ParamArray gCodes())
    17. Dim fType() As Integer, fData()
    18. Dim Index As Long, i As Long
    19. Index = LBound(gCodes) - 1
    20. For i = LBound(gCodes) To UBound(gCodes) Step 2
    21. Index = Index + 1
    22. ReDim Preserve fType(0 To Index)
    23. ReDim Preserve fData(0 To Index)
    24. fType(Index) = CInt(gCodes(i))
    25. fData(Index) = gCodes(i + 1)
    26. Next
    27. End Sub
    28. Public Function ssExtents(SS As AcadSelectionSet) As Variant
    29. Dim Points(), C As Long
    30. Dim Min As Variant, Max As Variant
    31. Dim i As Long, j As Long
    32. C = 0
    33. For i = 0 To SS.count - 1
    34. SS.Item(i).GetBoundingBox Min, Max
    35. ReDim Preserve Points(0 To C + 1)
    36. Points(C) = Min: Points(C + 1) = Max
    37. C = C + 2
    38. Next
    39. ssExtents = Extents(Points)
    40. End Function
    41. Public Function Extents(Points)
    42. Dim Min As Variant, Max As Variant
    43. Dim i As Long, j As Long, Pt, RetVal(0 To 1)
    44. Min = Points(LBound(Points))
    45. Max = Points(LBound(Points))
    46. For i = LBound(Points) To UBound(Points)
    47. Pt = Points(i)
    48. For j = LBound(Pt) To UBound(Pt)
    49. If Pt(j) < Min(j) Then Min(j) = Pt(j)
    50. If Pt(j) > Max(j) Then Max(j) = Pt(j)
    51. Next
    52. Next
    53. RetVal(0) = Min: RetVal(1) = Max
    54. Extents = RetVal
    55. End Function