Message 1 of 16
Is there a way to update attribute after changing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have been working on some code which will update the an attribute in a border on my drawings and have the following code:
Private Sub UpdateBlockAttributes_2()
Dim objEntity As AcadEntity
Dim objBlockRef As AcadBlockReference
Dim AttriList() As AcadAttributeReference
Dim dBlocks As New Dictionary
Dim i As Integer
dBlocks.CompareMode = TextCompare
Dim aDBX As AxDbDocument
Set aDBX = AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument." & Left$(ThisDrawing.GetVariable("AcadVer"), 2))
Call aDBX.Open("..[path to drawing]..")
For Each objEntity In aDBX.PaperSpace
If (TypeOf objEntity Is AcadBlockReference) Then
Set objBlockRef = objEntity
If ((Not dBlocks.Exists(objBlockRef.Name)) And (StrComp(objBlockRef.Name, "Border", vbTextCompare) = 0)) Then
If objBlockRef.HasAttributes Then
AttriList = objBlockRef.GetAttributes
For i = LBound(AttriList) To UBound(AttriList)
Select Case AttriList(i).TagString
Case "SHEET"
Debug.Print "Sheet found"
AttriList(i).TextString = "sheet"
End Select
Next
End If
End If
End If
Next
Call aDBX.SaveAs(aDBX.Name)
End Sub
Now, the code works in that the sheet attribute is updated but what it doesn't do is sync the position of the text and I am left with this:
which means I have to use ATTSYNC (manually from the drawing) in order to get this:
which is what it should look like.
So, I need a way to automate this so that after updating the text, the position is reset / sync'd...
Is there a way to do this? I had thought of calling ATTSYNC fromt SendCommand but this is not available in ObjectDBX. Is there another way?
Thanks