I added:
trans.Commit()
ed.Regen()
before the end using statement and it still doesn't work. This is what my code looks like now:
Dim cur_doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = cur_doc.Database
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = db.TransactionManager
Dim ed As Autodesk.AutoCAD.EditorInput.Editor = cur_doc.Editor
Dim filList() As TypedValue = {New TypedValue(DxfCode.BlockName, "RWLabel")}
Dim cur_filter = New Autodesk.AutoCAD.EditorInput.SelectionFilter(filList)
Dim id As ObjectId, ent1 As Autodesk.AutoCAD.DatabaseServices.BlockReference
Dim attrib As AttributeReference, attribdef As AttributeDefinition
Dim bt As BlockTable
Using docLock As DocumentLock = cur_doc.LockDocument
Using trans As Transaction = tm.StartTransaction
bt = trans.GetObject(cur_doc.Database.BlockTableId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead)
' ent1 = tm.GetObject(id, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite, True)
' For i = 0 To (ent1.AttributeCollection.Count - 1)
Dim bd As BlockTableRecord = tm.GetObject(bt("RWLabel"), Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
For Each adId As ObjectId In bd
Dim adObj As DBObject = trans.GetObject(adId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
' For each attribute definition we find...
If TypeOf adObj Is AttributeDefinition Then
attribdef = adObj
If Not attribdef Is Nothing Then
If newjust = "ML" Then
Dim pos As New Autodesk.AutoCAD.Geometry.Point3d(attribdef.Position.X, attribdef.Position.Y, attribdef.Position.Z)
attribdef.Justify = AttachmentPoint.BaseLeft
' attribdef.AlignmentPoint = pos
Else
Dim pos As New Autodesk.AutoCAD.Geometry.Point3d(attribdef.Position.X, attribdef.Position.Y, attribdef.Position.Z)
attribdef.Justify = AttachmentPoint.BaseRight
' attribdef.AlignmentPoint = attribdef.Position
End If
End If
End If
Next
trans.Commit()
ed.Regen()
End Using
End Using