Option Explicit
Public Sub ListPlus()
Dim sPrefix As String
Dim sSuffix As String
Dim selRes As AcadEntity
Dim selPoint As Variant
Dim dynBlockRef As AcadBlockReference
Dim atrCol As Object
Dim numAtrId As String
Dim i As Integer
sPrefix = "%<\AcExpr (%<\AcObjProp Object(%<\_ObjId "
sSuffix = ">%).TextString>%+1)>%"
On Error GoTo lErrorSelect
ThisDrawing.Utility.GetEntity selRes, selPoint, "\nSelect source block reference <Cancel> : "
On Error GoTo lErrorNoBlock
Set dynBlockRef = selRes
If dynBlockRef.EffectiveName.UCase = "РАМКА" Then
atrCol = dynBlockRef.GetAttributes
For i = LBound(atrCol) To UBound(atrCol)
If atrCol(i).TagString = "№" Then
numAtrId = CStr(atrCol(i).ObjectID)
GoTo lExitFor
End If
Next i
lExitFor:
On Error GoTo lErrorSelect
ThisDrawing.Utility.GetEntity selRes, selPoint, "\nSelect destination block reference <Cancel> : "
On Error GoTo lErrorNoBlock
Set dynBlockRef = selRes
If dynBlockRef.EffectiveName.UCase = "РАМКА" Then
atrCol = dynBlockRef.GetAttributes
For i = LBound(atrCol) To UBound(atrCol)
If atrCol(i).TagString = "№" Then
atrCol(i).TextString = sPrefix & numAtrId & sSuffix
atrCol(i).Update ' Вариант 1
GoTo lExitFor2
End If
Next i
lExitFor2:
dynBlockRef.Update ' Вариант 2
ThisDrawing.SendCommand "_.updatefield (handent " & Chr(34) & dynBlockRef.Handle & Chr(34) & ") " ' Вариант 3
End If
End If
Exit Sub
lErrorSelect:
ThisDrawing.Utility.Prompt "\nError selection"
On Error GoTo 0
Exit Sub
lErroBlock:
ThisDrawing.Utility.Prompt "\nThat's not block reference"
On Error GoTo 0
Exit Sub
End Sub