Change nested block attribute selected

Change nested block attribute selected

jplujan
Advocate Advocate
455 Views
1 Reply
Message 1 of 2

Change nested block attribute selected

jplujan
Advocate
Advocate

Hello, not if I could help someone.

 

I have a previously selected block and want to change an attribute of a block that is nested in the selected block.

 

 

Public Sub AtributosAnidados(Cadena As String, Inicio As Integer)
    Dim objBlk As AcadBlock
    Dim objBlkRef As AcadBlockReference
    Dim objEnt As AcadEntity
    Dim AttArray As Variant
    Dim i As Integer
       
    
    ThisDrawing.Utility.GetEntity objBlkRef, "Select object:"
 '*****I want only the selected block
    For Each objBlk In ThisDrawing.Blocks
        If objBlkRef.EffectiveName = Cadena Then
        i = Inicio
            For Each objEnt In objBlk
                If TypeOf objEnt Is AcadBlockReference Then
                    If objEnt.EffectiveName = "NVavula" Then
                    
                        If objEnt.HasAttributes Then
                            AttArray = objEnt.GetAttributes
                            If AttArray(0).TagString = "NUMVALVULA" Then
                                Debug.Print AttArray(0).TextString
                                AttArray(0).TextString = i
                            End If
                        End If
                    
                        i = i + 1
                     End If
                     
                End If
                
            Next
        End If
   Next
  
  Regen (acAllViewports)
End Sub

thanks in advance

0 Likes
456 Views
1 Reply
Reply (1)
Message 2 of 2

jplujan
Advocate
Advocate

I've managed to read only the nested blocks of a block code gives me nigun mistake aprentemente change all attributes of the nested blocks, but in the drawings is not updated.

 

 

Public Sub AtributosAnidados_B()
    Dim vItem1 As Variant
    Dim vItem2 As Variant
    Dim oBlkDefOut As AcadBlock
    Dim oBlkDefIn As AcadBlock
    Dim oBlkRefOut As AcadBlockReference
    Dim oBlkRefIn As AcadBlockReference
    Dim AttArray As Variant
    Dim i As Integer
    
    i = 10
    
    For Each vItem1 In ThisDrawing.Blocks
        If vItem1.name = "BPC-3CAL" Then
        Set oBlkDefOut = vItem1
        For Each vItem2 In oBlkDefOut
            If TypeName(vItem2) = "IAcadBlockReference" Then
                If vItem2.EffectiveName = "NVavula" Then
                Set oBlkRefIn = vItem2
                    If oBlkRefIn.HasAttributes Then
                        AttArray = oBlkRefIn.GetAttributes
                        If AttArray(0).TagString = "NUMVALVULA" Then
                            Debug.Print AttArray(0).TextString
                            AttArray(0).TextString = i
                            i = i + 1
                        End If
                    End If
                End If
            End If
        Next
        End If
    Next
    Regen (acAllViewports)
    MsgBox ("Terminado")
End Sub

Thank you

0 Likes