27 | 05 | 2017

Get Block Attributes .NET

The sample below show a code to access a blocks attributes using VB.NET

Private Sub GetBlockAttributes()

        Dim AcadApp As Object
        Dim dbxDoc As Object

        AcadApp = StartAutoCADSession()
        dbxDoc = AcadApp.Activedocument
        AcadApp.Visible = True

        Dim I As Integer
        Dim strAttributes As String
        Dim varAttributes As Object
        Dim entity As Object

        For Each entity In dbxDoc.PaperSpace

            If TypeName(entity) = "IAcadBlockReference" Then
                If entity.hasattributes = True Then

                    varAttributes = entity.GetAttributes
                    strAttributes = ""

                    For I = LBound(varAttributes) To UBound(varAttributes)

                        MsgBox("BLOCKNAME:  " & entity.name & vbCr _
                                & "TAG             :  " & varAttributes(I).TagString & vbCr _
                                & "VALUE         :  " & varAttributes(I).TextString)

                    Next
                End If
          End If
        Next entity

    End Sub
Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2262528
Latest Articles