Message 1 of 14
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to update a block attribute but I cannot get this code to work:
Private Sub UpdateBlockAttributes()
Dim objEntity As AcadEntity
Dim objBlockRef As AcadBlockReference
Dim AttriList() As AcadAttributeReference
Dim objAttributes 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("C:\Users\u\Desktop\Template.dwg")
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, "BorderBlk", vbTextCompare) = 0)) Then
If objBlockRef.HasAttributes Then
AttriList = objBlockRef.GetAttributes
For i = LBound(AttriList) To UBound(AttriList)
Select Case AttriList(i).TagString
Case "Issue"
Debug.Print "Issue found"
AttriList(i).TextString = "issue"
Case "Sheet"
Debug.Print "Sheet found"
AttriList(i).TextString = "sheet"
End Select
Next
End If
End If
End If
Next
End Sub
after I open the drawing again the attributes have not been updated.
I believe the attributes are being found in the blocks and I'm just setting them to an arbitary value for testing purposes but it doesn't look like they're either being set successfully or saved.
Does anyone know where this might be going wrong?
Thanks
Solved! Go to Solution.