Hi,
It looks like you didn't copy the whole code from TheSwamp: the GetAttributes() and ResetAttributes() methods are missing in the code you show.
With VB, you have to clear the Root Namespace in the project to add these extension methods to Autodesk.AutoCAD.DatabaseServices.
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Runtime
Namespace Autodesk.AutoCAD.DatabaseServices
Public Module ExtensionMethods
Dim attDefClass As RXClass = RXClass.GetClass(GetType(AttributeDefinition))
<System.Runtime.CompilerServices.Extension> _
Public Sub SynchronizeAttributes(target As BlockTableRecord)
If target Is Nothing Then
Throw New ArgumentNullException("target")
End If
Dim tr As Transaction = target.Database.TransactionManager.TopTransaction
If tr Is Nothing Then
Throw New Exception(ErrorStatus.NoActiveTransactions)
End If
Dim attDefs As List(Of AttributeDefinition) = target.GetAttributes(tr)
For Each id As ObjectId In target.GetBlockReferenceIds(True, False)
Dim br As BlockReference = _
DirectCast(tr.GetObject(id, OpenMode.ForWrite), BlockReference)
br.ResetAttributes(attDefs, tr)
Next
If target.IsDynamicBlock Then
target.UpdateAnonymousBlocks()
For Each id As ObjectId In target.GetAnonymousBlockIds()
Dim btr As BlockTableRecord = _
DirectCast(tr.GetObject(id, OpenMode.ForRead), BlockTableRecord)
attDefs = btr.GetAttributes(tr)
For Each brId As ObjectId In btr.GetBlockReferenceIds(True, False)
Dim br As BlockReference = _
DirectCast(tr.GetObject(brId, OpenMode.ForWrite), BlockReference)
br.ResetAttributes(attDefs, tr)
Next
Next
End If
End Sub
<System.Runtime.CompilerServices.Extension> _
Private Function GetAttributes(target As BlockTableRecord, tr As Transaction) As List(Of AttributeDefinition)
Dim attdefs As List(Of AttributeDefinition) = New List(Of AttributeDefinition)
For Each id As ObjectId In target
If id.ObjectClass = attDefClass Then
Dim attDef As AttributeDefinition = _
DirectCast(tr.GetObject(id, OpenMode.ForRead), AttributeDefinition)
attdefs.Add(attDef)
End If
Next
Return attdefs
End Function
<System.Runtime.CompilerServices.Extension> _
Private Sub ResetAttributes(br As BlockReference, attDefs As List(Of AttributeDefinition), tr As Transaction)
Dim attValues As New Dictionary(Of String, String)()
For Each id As ObjectId In br.AttributeCollection
If Not id.IsErased Then
Dim attRef As AttributeReference = _
DirectCast(tr.GetObject(id, OpenMode.ForWrite), AttributeReference)
attValues.Add( _
attRef.Tag, _
If(attRef.IsMTextAttribute, attRef.MTextAttribute.Contents, attRef.TextString))
attRef.Erase()
End If
Next
For Each attDef As AttributeDefinition In attDefs
Dim attRef As New AttributeReference()
attRef.SetAttributeFromBlock(attDef, br.BlockTransform)
If attDef.Constant Then
attRef.TextString = If(attDef.IsMTextAttributeDefinition, _
attDef.MTextAttributeDefinition.Contents, _
attDef.TextString)
Else If attValues IsNot Nothing AndAlso attValues.ContainsKey(attDef.Tag) Then
attRef.TextString = attValues(attDef.Tag.ToUpper())
End If
br.AttributeCollection.AppendAttribute(attRef)
tr.AddNewlyCreatedDBObject(attRef, True)
Next
End Sub
End Module
End Namespace