Results 1 to 1 of 1

Thread: How to get block attributes

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    Login to Give a bone

    Default How to get block attributes

    Hello to all,
    I am trying to catch block attributes from the attached drawing and to show them in listed in the msgbox.

    Here is a code that I have tried but I am not getting any message box after loading form and recognizing opened dwg:
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            'AutoCAD app
            Dim acadApp As AcadApplication
            acadApp = GetObject(, "AutoCAD.Application")
            'Active doc
            Dim dbxDoc As Object
            dbxDoc = acadApp.ActiveDocument
            acadApp.Visible = True
            Dim I As Integer
            Dim strAttributes As String
            Dim varAttributes As Object
            Dim entity As Object
            'Try to catch attributes from the opened dwg
            For Each entity In dbxDoc.PaperSpace
                If TypeOf entity Is AcadBlockReference Then
                    If entity.HasAttributeDefinitions = True Then
                        varAttributes = entity.GetAttributes
                        strAttributes = ""
                        For I = LBound(varAttributes) To UBound(varAttributes)
                            'Return catched blocks with their attributes
                            MsgBox("BLOCKNAME:  " & & vbCr _
                                    & "TAG             :  " & varAttributes(I).TagString & vbCr _
                                    & "VALUE         :  " & varAttributes(I).TextString)
                    End If
                End If
            Next entity
        End Sub
    I would appreciate if someone can help me cause I am struggling few days with this.
    Attached Files Attached Files

Similar Threads

  1. Replies: 1
    Last Post: 2014-06-16, 07:54 PM
  2. link dynamic block parameters with block attributes
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2012-06-12, 06:38 PM
  3. Replies: 2
    Last Post: 2012-06-06, 12:28 PM
  4. Replies: 21
    Last Post: 2007-03-20, 02:03 PM
  5. Extract Dynamic Block Attributes, values change as Block changes
    By dave.buckberry in forum Dynamic Blocks - Technical
    Replies: 11
    Last Post: 2006-09-05, 04:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts