Ahh thank you Alfred! I did get them confused.
So my current code feeds in the btr.id, find the attribute category then adds the value to the array:
Public Sub match_nonconstant_to_blockgrouparray(ByVal blkid As Object)
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Try
Dim btr As BlockTableRecord = TryCast(blkid.GetObject(OpenMode.ForRead), BlockTableRecord)
Dim ids As ObjectIdCollection = btr.GetBlockReferenceIds(True, True)
Dim btrId As ObjectId
For Each btrId In ids
Dim blkref As BlockReference = TryCast(btrId.GetObject(OpenMode.ForRead, False), BlockReference)
Dim attCol As AttributeCollection = blkref.AttributeCollection
For Each attId As ObjectId In attCol
Dim attRef As AttributeReference = DirectCast(tr.GetObject(attId, OpenMode.ForRead), AttributeReference)
If attRef.Tag.ToUpper = "CATEGORY" Then
blockgrouparray(z) = attRef.TextString
End If
Next
Next
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage(("Exception: " + ex.Message))
Finally
tr.Dispose()
End Try
End Sub
Would I change the code so that it just skips the whole blkid part? So its like this:
Public Sub match_nonconstant_to_blockgrouparray(ByVal blkref As Object)
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Try
Dim attCol As AttributeCollection = blkref.AttributeCollection
For Each attId As ObjectId In attCol
Dim attRef As AttributeReference = DirectCast(tr.GetObject(attId, OpenMode.ForRead), AttributeReference)
If attRef.Tag.ToUpper = "CATEGORY" Then
blockgrouparray(z) = attRef.TextString
End If
Next
Catch ex As Autodesk.AutoCAD.Runtime.Exception
ed.WriteMessage(("Exception: " + ex.Message))
Finally
tr.Dispose()
End Try
End Sub
Many thanks,
HD