Move Attribut-References with VBA

Hello out there,

I am trying to move Attribute-Refernces in certain blocks via VBA.
This is how far I got:

Public Sub MoveAttribute(dblXOffset As Double, dblYOffset As Double, strAttribute As String, strBlock As String)

    Dim MyObject As AcadObject
    Dim MyBlockRef As AcadBlockReference
    Dim MyAttRef As AcadAttributeReference
    Dim myY As Double
    Dim MyX As Double
    Dim MyAttributes As Variant
    
    For Each MyObject In ThisDrawing.ModelSpace
          
        If MyObject.ObjectName = "AcDbBlockReference" Then
       
            If MyObject.Name = strBlock Then
               
                Set MyBlockRef = MyObject
                MyAttributes = MyBlockRef.GetAttributes
               
                For Each MyAtt In MyAttributes
               
                    If MyAtt.TagString = strAttribute Then
                       
                        Set MyAttRef = MyAtt
                     
                        MyX = MyAttRef.InsertionPoint(0)
                        MyY = MyAttRef.InsertionPoint(1)
                        
                        MyX = MyX+dblXOffset
                        MyY = MyY+dblYOffset 
                        MyAttRef.InsertionPoint(0) = MyX
                        MyAttRef.InsertionPoint(1) = MyY
              
                        MyAttRef.Update
                        MyBlockRef.Update
                                                                                          
                    End If
                   
                Next
               
            End If
        End If
   
    Next
   
End Sub

The program runs but the Attributes don't move.

I am using BricsCAD 10.4.11.

BTW: Are there any recommendations for documentation of the BricsCAD SDE.

Thanks in advance and

Best reagards

Roman

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Click one of the buttons on the top bar to get involved!