AutoCad 2012...when using
db.ReadDwgFile(MyDwg, IO.FileShare.ReadWrite, False, "")
to change Attribute Values the Attribute will sometimes move
if i open the Drawing and run a audit on the drawing and regen then it moves back to is correct location
but if i use
Dim NewDoc As Document = Application.DocumentManager.Open(DocumentName, false)
and run the same code there is no problem.
so my question is why does it do that?
Sub SetAttributeValues(ByVal BlockReferenceID As ObjectId, ByVal AttributeTagsValues As Dictionary(Of String, String))
Dim DwgEditor As Editor = TryCast(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor, Editor)
Using myTrans As Transaction = BlockReferenceID.Database.TransactionManager.StartTransaction
Try
Dim myBRef As BlockReference = TryCast(BlockReferenceID.GetObject(OpenMode.ForRead), BlockReference)
Dim myAttCollection As AttributeCollection = TryCast(myBRef.AttributeCollection, AttributeCollection)
For Each myAttRefID As ObjectId In myAttCollection
Dim myAttRef As AttributeReference = TryCast(myAttRefID.GetObject(OpenMode.ForWrite), AttributeReference)
If AttributeTagsValues.ContainsKey(myAttRef.Tag) Then
myAttRef.TextString = AttributeTagsValues(myAttRef.Tag)
End If
Next
myTrans.Commit()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
DwgEditor.WriteMessage(ex.Message + vbLf + ex.StackTrace)
myTrans.Abort()
End Try
End Using
End Sub