Hi,
This code list block, list Attribute
See code --> br.Name for name of block
_
Public Sub ListBlock()
Dim ed As Editor =
AcApp.Application.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Try
Dim bt As BlockTable = CType(trans.GetObject(db.BlockTableId,
OpenMode.ForRead), BlockTable)
Dim btr As BlockTableRecord = CType(trans.GetObject(bt(btr.ModelSpace),
OpenMode.ForRead), BlockTableRecord)
Dim id As ObjectId
For Each id In btr
Dim Ent As Entity = CType(trans.GetObject(id, OpenMode.ForRead, False),
Entity)
If TypeOf ent Is BlockReference Then
Dim EntitySet As DBObjectCollection
ent.Explode(EntitySet)
Dim Blk As BlockReference = CType(ent, BlockReference)
Dim br As BlockTableRecord = CType(trans.GetObject(Blk.BlockTableRecord,
OpenMode.ForRead, False), BlockTableRecord)
ed.WriteMessage(vbNewLine + "Block name = " + br.Name + ControlChars.Lf)
'Get the attribute references,if any
Dim atts As AttributeCollection
atts = Blk.AttributeCollection
If atts.Count > 0 Then
ed.WriteMessage(vbNewLine + "ObjectId : " + br.ObjectId.ToString)
Dim attId As ObjectId
For Each attId In atts
Dim att As AttributeReference
att = CType(trans.GetObject(attId, OpenMode.ForRead, False),
AttributeReference)
ed.WriteMessage(vbNewLine + att.Tag + " " + att.TextString)
Next
End If
End If
Next
Catch ex As Exception
ed.WriteMessage("Error ListBlock")
Finally
trans.Dispose()
End Try
End Sub