.NET
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Attribute will sometimes move when changing it value
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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.Appli
Using myTrans As Transaction = BlockReferenceID.Database.TransactionManager.Start
and it only seems to do that on Attributes that are set to justificated = center
Solved! Go to Solution.
Re: Attribute will sometimes move when changing it value
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Hi,
You are missing code to adjust the block attribute position after changing its value: AttributeReference.AdjustAlignment(db)
Try this code:
Public Sub SetAttributeValues(blockReferenceID As ObjectId, attributeTagsValues As Dictionary(Of String, String)) Dim dwgEditor As Editor = TryCast(Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor, Editor) Dim db As Database = blockReferenceID.Database Dim workDb As Database Using myTrans As Transaction = db.TransactionManager.StartTransaction() Try Dim myBRef As BlockReference = TryCast(blockReferenceID.GetObject(OpenMode.ForRea d), BlockReference) If myBRef IsNot Nothing Then Dim myAttCollection As AttributeCollection = myBRef.AttributeCollection For Each myAttRefID As ObjectId In myAttCollection Dim myAttRef As AttributeReference = DirectCast(myAttRefID.GetObject(OpenMode.ForWrite) , AttributeReference) If attributeTagsValues.ContainsKey(myAttRef.Tag) Then myAttRef.TextString = attributeTagsValues(myAttRef.Tag) ' Adjust alignment of this attribute workDb = HostApplicationServices.WorkingDatabase HostApplicationServices.WorkingDatabase = db myAttRef.AdjustAlignment(db) HostApplicationServices.WorkingDatabase = workDb End If Next End If myTrans.Commit() Catch ex As Autodesk.AutoCAD.Runtime.Exception dwgEditor.WriteMessage(ex.Message + vbLf + ex.StackTrace) myTrans.Abort() End Try End Using End Sub
-Khoa
Re: Attribute will sometimes move when changing it value
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
thank you
Re: Attribute will sometimes move when changing it value
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
You are welcome.
-Khoa
