Problem with editing attributes in a block

- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- パーマリンクを表示
- 印刷
- 報告
I'm trying to edit the attributes in a titleblock using VB.net. The block name is "Titleblock". It is already inserted into a drawing. My program does not need to insert it. It only needs to find the reference, for all layouts, and update a couple attributes for the titleblock on everylayout. I know some of the basics, but get confused with blocktables, and blocktablerecords.
Here is a piece of code I was experimenting with. With this code, I'm trying to get to the attributes, and read an attribute value for a drawing number. It fails when I try to assign a value to the variable blkreftitle. Any help and suggestions would be greatly appreciated.
Dim
doc AsDocument = Application.DocumentManager.MdiActiveDocument
Using docLoc AsDocumentLock = doc.LockDocument
Dim db AsDatabase = HostApplicationServices.WorkingDatabase
Using tr AsTransaction = db.TransactionManager.StartTransaction
Dim bt AsBlockTable = db.BlockTableId.GetObject(OpenMode.ForRead)
Dim blID AsObjectId = bt("TITLEBLOCK")
Dim blkRefTitle AsBlockReference = blID.GetObject(OpenMode.ForRead)
Dim myAttColl AsAttributeCollection = blkRefTitle.AttributeCollection
ForEach myAttRefId AsObjectIdIn myAttColl
Dim myAttRef AsAttributeReference = myAttRefId.GetObject(OpenMode.ForWrite)
If myAttRef.Tag = "DWGNUM"Then
strDwgNum = myAttRef.TextString
MsgBox(strDwgNum)
EndIf
Next
tr.Commit()
EndUsing
EndUsing