Может кому пригодится: реализовал поиск текста (mtext, text) по подстроке во всех лэйаутах (цикл по всем обьектам лэйаута), простенький интерфейс, возможность перехода на найденный элемент - он становиться подсвеченным (highlight) и выбранным (grips), его видно на экране (на него позиционируется рабочее окно).
Private Sub find_substr()
Dim spaceBlk As AcadBlock
Dim my_mtxt As AcadMText
Dim my_txt As AcadText
If TextBox1.Text = "" Then Exit Sub
ListView1.ListItems.Clear
find_str = LCase(TextBox1.Text)
For i = 1 To ThisDrawing.Blocks.Count - 1
If ThisDrawing.Blocks(i).IsLayout = True Then
my_space = ThisDrawing.Blocks(i).Layout.Name
Set spaceBlk = ThisDrawing.Blocks(i).Layout.Block
For j = 0 To spaceBlk.Count - 1
If TypeOf spaceBlk.Item(j) Is AcadMText Then
Set my_mtxt = spaceBlk.Item(j)
my_str = LCase(my_mtxt.TextString)
If InStr(1, my_str, find_str) > 0 Then
Set my_lst = ListView1.ListItems.Add(, , my_space)
my_lst.SubItems(1) = my_str
my_lst.SubItems(2) = i
my_lst.SubItems(3) = j
End If
End If
If TypeOf spaceBlk.Item(j) Is AcadText Then
Set my_txt = spaceBlk.Item(j)
my_str = LCase(my_txt.TextString)
If InStr(1, my_str, find_str) > 0 Then
Set my_lst = ListView1.ListItems.Add(, , my_space)
my_lst.SubItems(1) = my_str
my_lst.SubItems(2) = i
my_lst.SubItems(3) = j
End If
End If
Next j
End If
Next i
End Sub
'================================
'================================
Private Sub CommandButton1_Click()
find_substr
End Sub
Private Sub CommandButton2_Click()
Dim my_mtxt As AcadMText
Dim ssobjs(0) As AcadEntity
Dim ssetobj As AcadSelectionSet
Dim selset As AcadSelectionSet
If ListView1.ListItems.Count = 0 Then Exit Sub
i = ListView1.SelectedItem.Index
List_name = ListView1.SelectedItem.Text
ThisDrawing.WindowState = acMax
Set my_mtxt = ThisDrawing.Blocks(Val(ListView1.ListItems(i).SubItems(2))).Layout.Block.Item(Val(ListView1.ListItems(i).SubItems(3)))
my_mtxt.GetBoundingBox minp, Maxp
v = ThisDrawing.Blocks(Val(ListView1.ListItems(i).SubItems(2))).Layout.Block.Item(Val(ListView1.ListItems(i).SubItems(3))).Handle
ThisDrawing.SendCommand "(setq ss (ssadd))" + vbCr
ThisDrawing.SendCommand "(ssadd (handent """ + v + """) ss)" + vbCr
ThisDrawing.SendCommand "(sssetfirst ss ss)" + vbCr
ThisDrawing.ActiveLayout = ThisDrawing.Layouts(List_name)
Application.ZoomWindow minp, Maxp
ThisDrawing.Regen acAllViewports
ThisDrawing.SendCommand "REGEN" + vbCr
ThisDrawing.Regen acAllViewports
End
End Sub
'================================
'================================
Private Sub ListView1_DblClick()
If ListView1.ListItems.Count = 0 Then Exit Sub
CommandButton2_Click
End Sub
'================================
'================================
Private Sub UserForm_Activate()
ListView1.View = lvwReport
ListView1.LabelEdit = lvwManual
ListView1.GridLines = True
ListView1.ColumnHeaders.Add Text:="Лист"
ListView1.ColumnHeaders.Add Text:="Текст", Width:=600
ListView1.ColumnHeaders.Add Text:="N1"
ListView1.ColumnHeaders.Add Text:="N2"
ListView1.ColumnHeaders(3).Width = 10
ListView1.ColumnHeaders(4).Width = 10
End Sub