用以下程序就可以得到所有布局中的文字:- Public Sub BuildFilter(typeArray, dataArray, ParamArray gCodes())
- Dim fType() As Integer, fData()
- Dim index As Long, i As Long
-
- index = LBound(gCodes) - 1
-
- For i = LBound(gCodes) To UBound(gCodes) Step 2
- index = index + 1
- ReDim Preserve fType(0 To index)
- ReDim Preserve fData(0 To index)
- fType(index) = CInt(gCodes(i))
- fData(index) = gCodes(i + 1)
- Next
- typeArray = fType: dataArray = fData
- End Sub
- Function CreateSelectionSet(Optional SSetName As String = "mjtd") As AcadSelectionSet
- On Error Resume Next
- ThisDrawing.SelectionSets(SSetName).Delete
- Set CreateSelectionSet = ThisDrawing.SelectionSets.Add(SSetName)
- End Function
- Sub SelectAllLayoutText()
- Dim ss As AcadSelectionSet
- Set ss = CreateSelectionSet
- Dim typeArray As Variant
- Dim dataArray As Variant
- BuildFilter typeArray, dataArray, 0, "TEXT"
- ss.Select acSelectionSetAll, , , typeArray, dataArray
- Debug.Print ss.Count
- End Sub
特别提示:Select 的 acSelectionSetAll 项所选择的是所有图形中的对象,不管对象是在哪个空间或布局中。
如果需要过滤出某个布局中的对象,则使用实用函数中的以下函数解决:
http://www.mjtd.com/function/list.asp?id=304&ordertype=bysort&orderkey=33 |