<CommandMethod("SERACHINGONLYBLOCKBYNAME")>
Public Sub SERACHINGONLYBLOCKBYNAME()
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
If acDoc IsNot Nothing Then
Dim acDB As Database = acDoc.Database
Dim acEd As Editor = acDoc.Editor
Using tr = acDB.TransactionManager.StartTransaction()
Dim acSelSetPrompt As PromptSelectionResult = acEd.SelectAll
Dim acSSet = acSelSetPrompt.Value
For Each acSelSetObj As SelectedObject In acSSet
Try
If acSelSetObj IsNot Nothing Then
If tr.GetObject(acSelSetObj.ObjectId, OpenMode.ForRead).GetType.ToString = "Autodesk.AutoCAD.DatabaseServices.BlockReference" Then
Dim blkRef As BlockReference = tr.GetObject(acSelSetObj.ObjectId, OpenMode.ForRead)
Dim block As BlockTableRecord = Nothing
If blkRef.IsDynamicBlock Then
block = tr.GetObject(blkRef.DynamicBlockTableRecord, OpenMode.ForRead)
Else
block = tr.GetObject(blkRef.BlockTableRecord, OpenMode.ForRead)
End If
If block.Name = "Рамка_v4" Then
Dim blockTableRecord As BlockTableRecord = tr.GetObject(blkRef.OwnerId, OpenMode.ForRead) ' Очень просто находим ObjectID листа
If blockTableRecord.IsLayout Then
Dim layt As Layout = tr.GetObject(blockTableRecord.LayoutId, OpenMode.ForRead) ' Здесь его определяем по ObjectID
MsgBox("Это блок Рамка_v4 и находится он на листе " & layt.LayoutName) ' Сюда выводим его имя!!!
End If
End If
End If
End If
Catch ex As Autodesk.AutoCAD.Runtime.Exception
End Try
Next
End Using
End If
End Sub