Quantcast
Channel: Autodesk AutoCAD forums
Viewing all articles
Browse latest Browse all 14319

Select block from selection set and edit it's attributes.

$
0
0

Greetings,

 

I have multyple blocks on specific coorrinates in the model space. I'm tring to select one block at the time and edit it's attributes. With two words - to change the page number of sheets. So far i'm able to select without user input giving some coordinates and i can change the attribute of a block using user selecting the block. I cannot connect the two things or i'm doing it all wrong.

 

This is the part that i select the block:

Private Sub CommandButton2_Click()
Dim BlockRef As AcadBlockReference
Dim inspt As Variant
    Dim oEnt As AcadEntity
    Dim i
    Dim SelectBlockPnt1(0 To 2) As Double
    Dim SelectBlockPnt2(0 To 2) As Double
    Dim V_BlockSelection As AcadSelectionSet
      Set V_BlockSelection = ThisDrawing.SelectionSets.Add("BlockSelect3")
      SelectBlockPnt1(0) = 400: SelectBlockPnt1(1) = 11: SelectBlockPnt1(2) = 0
      SelectBlockPnt2(0) = 380: SelectBlockPnt2(1) = 5: SelectBlockPnt2(2) = 0
      V_BlockSelection.Select acSelectionSetWindow, SelectBlockPnt1, SelectBlockPnt2

This is the part where i change the attribute but i need to point the block: I found it in a forum

    ThisDrawing.Utility.GetEntity oEnt, inspt, "Select object:"
    ' Checks if you selected a block.
    If TypeOf oEnt Is AcadBlockReference Then
        Set oBlkRef = oEnt
        ' Check for attributes.
        If oBlkRef.HasAttributes Then
            Dim AttList As Variant
            ' Build a list of attributes for the current block.
            AttList = oBlkRef.GetAttributes
            ' Cycle throught the list of attributes.
            For i = LBound(AttList) To UBound(AttList)
                ' Check for the correct attribute tag.
                If AttList(i).TagString = "SHT" Then
                MsgBox "Hello World!"
                    'ParentSymbolForm.ComponetTag.Text = AttList(i).TextString
                    UserForm1.TextBox1.Text = AttList(i).TextString
                    UserForm1.Show
                    'this part is still under construction.
               End If
      Next
      End If
 Else
        MsgBox "You did not select a block."
    End If
    V_BlockSelection.Delete
End Sub

 Regards,

 

Kristiyan


Viewing all articles
Browse latest Browse all 14319

Trending Articles