title: Autocad API , reading block attributes casting error
body: <p>I am receiving following error that </p>
  
  <blockquote>
    <p>"Unable to cast object of type<br>
    autodesk.autocad.databaseservices.polyline to type 
    autodesk.autocad.databaseservices.blockrefereance</p>
  </blockquote>
  
  <p>while reading block attributes with lot of stuff on drawing.</p>
  
  <p>Code:</p>
  
  <pre><code>Dim db As Database = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database
  
  Using tr As Transaction = db.TransactionManager.StartTransaction
  
  Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
  Dim blockids As ObjectIdCollection = New ObjectIdCollection
  Dim bt As BlockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
  Dim btr As BlockTableRecord = tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead)
  
  For Each objid As ObjectId In btr
  
      If btr.IsAnonymous = False Or btr.IsLayout = False Then
  
          Dim blkref As BlockReference = tr.GetObject(objid, OpenMode.ForRead)
  
          Dim attcol As AttributeCollection = blkref.AttributeCollection
  
          For Each attid As ObjectId In attcol
  
              Dim attref As AttributeReference = tr.GetObject(attid, OpenMode.ForRead)
  
              ed.WriteMessage(attref.Tag.ToString &amp; vbNewLine)
  
              ed.WriteMessage(attref.TextString.ToString &amp; vbNewLine)
  
          Next
  
      End If
  
  Next
  
  tr.Commit()
  
  End Using
  </code></pre>
  
  <p>Can you please help!!!</p>