Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Despite having "att.AdjustAlignment(db)", the text alignment is off once the values have been updated. I'm not sure why "att.AdjustAlignment(db)" isn't working. Please help.
Public Sub UpdateAecFileAttributes(ByVal Directory_DrawingName As String, ByVal PassedBlkName As String, ByVal dtTagValue As Data.DataTable)
Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim db As New Database '= New Database(False, True)
Dim wdb As Database = HostApplicationServices.WorkingDatabase
Dim blkref = RXObject.GetClass(GetType(BlockReference))
Dim blk As BlockReference
AecFullFileName = Directory_DrawingName
AecFilePath = IO.Path.GetDirectoryName(AecFullFileName)
AecFileName = IO.Path.GetFileNameWithoutExtension(AecFullFileName)
Using db
Try
db.ReadDwgFile(AecFullFileName, FileOpenMode.OpenForReadAndAllShare, False, Nothing)
Catch __unusedException1__ As System.Exception
ed.WriteMessage(vbLf & "Unable To read drawing file.")
End Try
Using tran = db.TransactionManager.StartTransaction()
Dim loDic As DBDictionary = CType(tran.GetObject(db.LayoutDictionaryId, OpenMode.ForWrite, False), DBDictionary)
For Each entry As DBDictionaryEntry In loDic
Dim layout = CType(tran.GetObject(entry.Value, OpenMode.ForWrite), Layout)
Dim btr As BlockTableRecord = CType(tran.GetObject(layout.BlockTableRecordId, OpenMode.ForWrite), BlockTableRecord)
For Each objID As ObjectId In btr
If objID.ObjectClass.IsDerivedFrom(blkref) Then
blk = CType(tran.GetObject(objID, OpenMode.ForWrite), BlockReference)
If Not blk.BlockTableRecord.IsNull And blk IsNot Nothing Then
Dim attCol = blk.AttributeCollection
Dim blkName As String
If blk.IsDynamicBlock Then
blkName = FetchEffectiveName(blk)
Else
blkName = blk.Name
End If
If blkName = PassedBlkName Then
If attCol IsNot Nothing Then
For Each attobjId As ObjectId In attCol
Dim att As AttributeReference = CType(tran.GetObject(attobjId, OpenMode.ForWrite), AttributeReference)
Dim attTag As String = att.Tag
For i As Integer = 0 To dtTagValue.Rows.Count - 1
If attTag = dtTagValue.Rows(i)(0) Then
att.TextString = dtTagValue.Rows(i)(1)
End If
Next
att.AdjustAlignment(db)
HostApplicationServices.WorkingDatabase = wdb
Next
End If
End If
End If
End If
Next
Next
tran.Commit()
End Using 'tran
Try
db.SaveAs(AecFullFileName, DwgVersion.Current)
ed.WriteMessage(vbLf & AecFileName & " saved.")
Catch __unusedException1__ As System.Exception
ed.WriteMessage(vbLf & "Unable To save.")
End Try
End Using 'db
End Sub
Solved! Go to Solution.