<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get into the blocks and return block names and attributes in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7002368#M32106</link>
    <description>&lt;P&gt;You keep on confusing .NET API and COM API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As you said you want to build an out-of-process (standalone exe) application, you CANNOT use the .NET API.&lt;/P&gt;
&lt;P&gt;So, remove all references to AutoCAD managed libraries (aacormgd, acdbmgd and acmgd) from your project, remove also all imports of the related namespaces.&lt;/P&gt;
&lt;P&gt;Reference AutoCAD COM interop libraries (Autodesk.AutoCAD.Interop and Autodesk.AutoCAD.Interop.Common) and Import these namespace.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the last code you said it worked, not tested (VB and COM API are really boring me).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Imports Microsoft.Office
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Word
Imports System.IO
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common

Public Class Form1

    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 ss As AcadSelectionSet
        Dim ent As AcadEntity
        Dim blk As AcadBlockReference

        '' Create a selectionset to select everything in drawing (or with filter to select only "INSERT"
        ss = dbxDoc.SelectionSets.Add("test")

        ss.Select(AcSelect.acSelectionSetAll)

        For Each ent In ss
            If TypeOf ent Is AcadBlockReference Then
                blk = ent
                If blk.HasAttributes Then
                    Dim text As String = "Find block with attribute: " &amp;amp; blk.EffectiveName &amp;amp; "."
		    For Each att As AcadAttributeReference In blk.GetAttributes()
			text = text &amp;amp; vbCr &amp;amp; att.TagString &amp;amp; ": " &amp;amp; att.TextString
		    Next
                    MsgBox(text)
                End If
            End If
        Next
	End Sub
End Clas&lt;/PRE&gt;</description>
    <pubDate>Fri, 07 Apr 2017 10:21:39 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2017-04-07T10:21:39Z</dc:date>
    <item>
      <title>Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6981272#M32070</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Could someone help me with this? I would like to get all block with attributes in the opened drawing and to list the names of the blocks and their attribute's tags/values. So, firstly, I am trying to get the information about block names.&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'AutoCAD app&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim acadApp As AcadApplication&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; acadApp = GetObject(, "AutoCAD.Application")&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Active doc&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim dbxDoc As Object&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dbxDoc = acadApp.ActiveDocument&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; acadApp.Visible = True&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim entity As Object&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Catch blocks from the opened dwg&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each entity In dbxDoc.PaperSpace&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If TypeOf entity Is AcadBlockReference Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MsgBox(entity.GetType.Name)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next entity&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/PRE&gt;
&lt;P&gt;Using code from the above the form is loaded but I am not getting the response about the block's name.&lt;/P&gt;
&lt;P&gt;I am using AutoCAD 2017 and VB2015.&lt;/P&gt;
&lt;P&gt;Many thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 13:30:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6981272#M32070</guid>
      <dc:creator>danijel.radenkovic</dc:creator>
      <dc:date>2017-03-29T13:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6982169#M32071</link>
      <description>&lt;P&gt;Since you are posting in AutoCAD .NET forum, Please to be aware that ".NET" as forum name is mainly meant for "AutoCAD .NET API" (naturally the programming language should be .NET language), and much less meant for using MS .NET in general. Thus the very first question a potential respondent to your post would possibly be: is there any particular reason for you to use AutoCAD COM API instead of .NET API? Then, the next possible question would be are you doing an out-porocess application (EXE app that automate AutoCAD instance) and why? Answers to these 2 questions would determine the usefulness of replies to your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, regarding to&amp;nbsp;AutoCAD programming, we need to be very careful to use term "block", ofter, it is better to explicitly say "block definition" and "block reference". according to your question, do you want to list all names of defined blocks (block definitions) in the drawing (or limited to the block definitions that have Attribute defined in them)? Or, do you only want to list the blocks that visible (thus, block references) and with attribute references?&lt;/P&gt;</description>
      <pubDate>Wed, 29 Mar 2017 17:43:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6982169#M32071</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2017-03-29T17:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6983448#M32072</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Since you are posting in AutoCAD .NET forum, Please to be aware that ".NET" as forum name is mainly meant for "AutoCAD .NET API" (naturally the programming language should be .NET language), and much less meant for using MS .NET in general. Thus the very first question a potential respondent to your post would possibly be: is there any particular reason for you to use AutoCAD COM API instead of .NET API? Then, the next possible question would be are you doing an out-porocess application (EXE app that automate AutoCAD instance) and why? Answers to these 2 questions would determine the usefulness of replies to your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, regarding to&amp;nbsp;AutoCAD programming, we need to be very careful to use term "block", ofter, it is better to explicitly say "block definition" and "block reference". according to your question, do you want to list all names of defined blocks (block definitions) in the drawing (or limited to the block definitions that have Attribute defined in them)? Or, do you only want to list the blocks that visible (thus, block references) and with attribute references?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Thank you for the reply.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;1. Is there any particular reason for you to use AutoCAD COM API instead of .NET API?&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;I have found few similar posts about retriving "block definition" information and I have tried with the current code.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;2. Are you doing an out-porocess application (EXE app that automate AutoCAD instance) and why?&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The only thing that I would like to do is to get the attributes using vb.net application that I have created in the past. I would like to update my vb.net project with adding a possibility to iterate with AutoCAD 2017, so that is the reason why I am going via .exe application.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;&lt;EM&gt;3. Do you want to list all names of defined blocks (block definitions) in the drawing (or limited to the block definitions that have Attribute defined in them)? Or, do you only want to list the blocks that visible (thus, block references) and with attribute references?&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;I would like to catch only block with the attributes, so I have tried firstly to list all blocks and after to set condition if current block definition has attributes then get the value of the attribute, if it has not then nothing.&lt;/P&gt;
&lt;P&gt;Any help is very appreciated.&lt;/P&gt;
&lt;P&gt;Danijel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2017 06:53:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6983448#M32072</guid>
      <dc:creator>danijel.radenkovic</dc:creator>
      <dc:date>2017-03-30T06:53:50Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6986315#M32073</link>
      <description>&lt;P&gt;I concur with my colleague Norman - and as he has pointed out, i think it's best to use in-process solution rather than COM interop unless you have a good reason for using the latter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-NET/files/GUID-BA69D85A-2AED-43C2-B5B7-73022B5F28F8-htm.html" target="_blank"&gt;https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-NET/files/GUID-BA69D85A-2AED-43C2-B5B7-73022B5F28F8-htm.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the above code will be inordinately helpful to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you can get the name of the block reference via the .Name property.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;any probs pls ask.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(I would also add that since you're writing in VB.Net why not take the trouble right now to switch to c#. IMO it's easier and there are more code xamples on the forums etc. ) best wishes&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 03:20:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6986315#M32073</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2017-03-31T03:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6986543#M32075</link>
      <description>&lt;P&gt;Hello to all,&lt;/P&gt;
&lt;P&gt;Thank you very much for the help that you providing.&lt;/P&gt;
&lt;P&gt;Few weeks ago, I have tried code that you provided but I had a problem to debug. The error that I have not solved was showed on the image bellow. I have tried to solve syntax problem with using potential fixes but I didn't have a success.&lt;/P&gt;
&lt;P&gt;The reason why I have continued with vb.net instead of moving to C# is because I have almost finished project that has to be updated with new function (iterating with AutoCAD), but I have decided to move on C# after that.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image1.PNG" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/339706iC7C58CA1AB05C357/image-size/large?v=v2&amp;amp;px=999" role="button" title="image1.PNG" alt="image1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Any help is very appreciated.&lt;/P&gt;
&lt;P&gt;Danijel&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 07:16:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6986543#M32075</guid>
      <dc:creator>danijel.radenkovic</dc:creator>
      <dc:date>2017-03-31T07:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6987221#M32076</link>
      <description>&lt;P&gt;I can still see 2 major issues:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. You still use "block", even though I pointed out it is not clear what you want to list: block definition (with attribute definition), or block reference (with attribute reference). The result list would be different (unless the drawing is purged. that is, all block definitions in the drawing have block references created). In your previous reply you said "&lt;SPAN&gt;current block definition has attributes then get the value of the attribute". Mind you, attribute in block definition DOES NOT have value, attribute in block reference does. That is why you need to be clear: do you want to list block definitions, or do you want to list block references?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. Since you are doing EXE, you can only use AutoCAD COM API. You CANNOT use AutoCAD .NET API. So, the code shown in your latest post does not help you at all.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Now, let's assume you still go with COM API. To list all block definitions that include attribute, you do (pseudo-code)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim ent As AcadEntity&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim blk As AcadBlock&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim hasAtt As Boolean&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim count As Integer&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For Each blk in ThisDrawing.Blocks&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; hasAtt=False&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; For Each ent In blk&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If TypeOf ent Is AcadAttribute Then&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MsgBox "Block """ &amp;amp; blk.Name &amp;amp; """ has attribute."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;count+count+1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Exit For&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; End If&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Next&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Next&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;MsgBox count &amp;amp; " block definitions are found having attribute"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you only want a block name list of VISIBLE blocks (block reference) that has attribute (attribute reference), then you can do:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim ss As AcadSelection&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim ent As AcadEntity&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim blk As AcadBlockReference&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;'' Create a selectionset to select everything in drawing (or with filter to select only "INSERT"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Set ss=ThisDrawing.SelectionSets.Add("test")&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ss.Select acSelectionSetAll&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For Each entin ss&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; If TypeOf ent Is AcadBlockReference Then&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Set blk=ent&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; If blk.HasAttributes Then&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; MsgBox "Find block with attribute: """ &amp;amp; blk.EffectiveName &amp;amp; """."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; End If&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; End If&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Next&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Notice I use EffectiveName, in case the blockreference is a dynamic one. Of course, since there could be multiple block references to a block definition, the names obtained here could be duplicated. Also just to be aware: block reference can have attribute, or not have attribute regardless if the block definition it is based on has attribute defined in it or not (yes, it is unusual, but could happen), that is why I ask you to be clear: do you want to list name out of block definitions, or do you want to list names out of block references.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 13:34:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6987221#M32076</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2017-03-31T13:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6988487#M32077</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then the easiest solution is to go to this site:&amp;nbsp;&lt;A href="http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;amp;id=18162650" target="_blank"&gt;http://usa.autodesk.com/adsk/servlet/index?siteID=123112&amp;amp;id=18162650&lt;/A&gt; download the ObjectArx and Wizards. After you download the Wizards next time you go into visual studio create a new autocad template.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created a screencast hope it helps: &amp;nbsp;&lt;A href="http://autode.sk/2oj4ZQI" target="_blank"&gt;http://autode.sk/2oj4ZQI&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 22:34:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6988487#M32077</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2017-03-31T22:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6989428#M32084</link>
      <description>&lt;P&gt;I have downloaded &lt;A href="http://images.autodesk.com/adsk/files/ObjectARXWizards-2017.zip" target="_blank"&gt;ObjectARX 2017 Wizard&lt;/A&gt;&amp;nbsp; and &lt;A href="http://images.autodesk.com/adsk/files/AutoCAD_2017_dotnet_wizards.zip" target="_blank"&gt;AutoCAD 2017 DotNet Wizards&lt;/A&gt; and installed them. Templates are only visible if the .Net Framework 4.5 is chosen. In the past, I have installed for the Inventor and it works perfect as it is showed on the image bellow, even if the .NET Framework 4.6 is chosen. It is not a problem to switch my project to v4.5.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="img.PNG" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/340199iECFDDB838E0D7878/image-size/large?v=v2&amp;amp;px=999" role="button" title="img.PNG" alt="img.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Your screencast helped me to understand possible ways of iterating with AutoCAD, so please correct me if I am wrong.&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Using AutoCAD .NET API=&amp;gt;you said ACAD has to be opened. Using NETLOAD, I am loading a plug-in (.dll file). By calling a command I am running a code.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;In previous example "GettingAttributes" could be a command to run the code.&lt;/P&gt;
&lt;P&gt;This is probably better way to iterate with AutoCAD but I would like to avoid typing of commands in AutoCAD. My idea is get all attribute values (see the image bellow) of the blocks in the opened drawing by clicking on the button on my form.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.PNG" style="width: 700px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/340200iC9F9B88E09D12BF8/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.PNG" alt="1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;OL start="2"&gt;
&lt;LI&gt;Using AutoCAD COM API=&amp;gt; you said ACAD don't need to be opened. But my idea is to work with the opened drawing and I believe it is not a problem.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Apr 2017 20:25:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6989428#M32084</guid>
      <dc:creator>danijel.radenkovic</dc:creator>
      <dc:date>2017-04-01T20:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6989510#M32085</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I can still see 2 major issues:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. You still use "block", even though I pointed out it is not clear what you want to list: block definition (with attribute definition), or block reference (with attribute reference). The result list would be different (unless the drawing is purged. that is, all block definitions in the drawing have block references created). In your previous reply you said "&lt;SPAN&gt;current block definition has attributes then get the value of the attribute". Mind you, attribute in block definition DOES NOT have value, attribute in block reference does. That is why you need to be clear: do you want to list block definitions, or do you want to list block references?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2. Since you are doing EXE, you can only use AutoCAD COM API. You CANNOT use AutoCAD .NET API. So, the code shown in your latest post does not help you at all.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Now, let's assume you still go with COM API. To list all block definitions that include attribute, you do (pseudo-code)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim ent As AcadEntity&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim blk As AcadBlock&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim hasAtt As Boolean&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim count As Integer&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For Each blk in ThisDrawing.Blocks&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; hasAtt=False&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; For Each ent In blk&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; If TypeOf ent Is AcadAttribute Then&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;MsgBox "Block """ &amp;amp; blk.Name &amp;amp; """ has attribute."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;count+count+1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Exit For&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; End If&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Next&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Next&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;MsgBox count &amp;amp; " block definitions are found having attribute"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you only want a block name list of VISIBLE blocks (block reference) that has attribute (attribute reference), then you can do:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim ss As AcadSelection&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim ent As AcadEntity&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dim blk As AcadBlockReference&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;'' Create a selectionset to select everything in drawing (or with filter to select only "INSERT"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Set ss=ThisDrawing.SelectionSets.Add("test")&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;ss.Select acSelectionSetAll&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For Each entin ss&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; If TypeOf ent Is AcadBlockReference Then&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Set blk=ent&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; If blk.HasAttributes Then&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; MsgBox "Find block with attribute: """ &amp;amp; blk.EffectiveName &amp;amp; """."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; End If&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; End If&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Next&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Notice I use EffectiveName, in case the blockreference is a dynamic one. Of course, since there could be multiple block references to a block definition, the names obtained here could be duplicated. Also just to be aware: block reference can have attribute, or not have attribute regardless if the block definition it is based on has attribute defined in it or not (yes, it is unusual, but could happen), that is why I ask you to be clear: do you want to list name out of block definitions, or do you want to list names out of block references.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hello &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I am little bit confused about terms that you mentioned. But according to your sentence: "&lt;EM&gt;Mind you, attribute in block definition DOES NOT have value, attribute in block reference does.&lt;/EM&gt;" and also according to my drawing (attached file), it seems that I am actually looking for value in the attribute of block reference.&lt;/P&gt;
&lt;P&gt;I have tried first part of code that you provided and I have got the names of all block definitions. But, as you said, if the drawing space is empty and if I run the code again, I will get the same answer. It's because the drawing is not purged.&lt;/P&gt;
&lt;P&gt;Second part of your code looks like VBA code. I have adapted to vb2015 syntax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dim ss As AcadSelectionSet
        Dim ent As AcadEntity
        Dim blk As AcadBlockReference

        '' Create a selectionset to select everything in drawing (or with filter to select only "INSERT"
        ss = dbxDoc.SelectionSets.Add("test")

        ss.Select(AcSelect.acSelectionSetAll)

        For Each ent In ss
            If TypeOf ent Is AcadBlockReference Then
                blk = ent
                If blk.HasAttributes Then
                    MsgBox("Find block with attribute: " &amp;amp; blk.EffectiveName &amp;amp; ".")
                End If
            End If
        Next&lt;/PRE&gt;
&lt;P&gt;Now, when I have got the list of all visible blocks, I would like to list the attributes. According to my drawing, should be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;TITLEBLOCK and the attributes are: Circle Block 1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;TITLEBLOCK and the attributes are: Circle Block 2&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;RECTANG_BLOCK and the attributes are: Top_Left text and Bottom_Left text and Bottom_Right text and Top_Right text&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;At the end of the video, you can see that I have tried to run the code again but second debugging was not successful. Would you like to explain me why?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 Apr 2017 22:44:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6989510#M32085</guid>
      <dc:creator>danijel.radenkovic</dc:creator>
      <dc:date>2017-04-01T22:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6989623#M32086</link>
      <description>&lt;P&gt;Hi Danijel what my learned colleague Norman is referring to is this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are two separate concepts at play here. Block definitions. and block references. they are related but different.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Imagine I create a block called: "chair". The chair consists of the following lines. This is a block definition. It is saved somewhere in the Block table. Right now there are no chairs showing in my autocad drawing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But what if I want to insert 200 chairs into my autocad drawing? Every chair is exactly the same. So rather than copy the chair 200 times what autocad does is something very smart - it creates 200 "block references". There is only one chair. This is stored in the block table. But there are 200 &lt;EM&gt;&lt;STRONG&gt;references&lt;/STRONG&gt;&lt;/EM&gt; to that chair. we save memory by doing this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But not all &lt;EM&gt;block&amp;nbsp;&lt;/EM&gt;&lt;EM&gt;references&lt;/EM&gt; are the same. some might have different attribute values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what you want i think is to get the attribute values of some block references which exist in your autocad drawing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this code will help - but it's in c#. the concepts are the same:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;public static string GetAV(ObjectId id, string attributeName) //pass in the blockreferenceID of the blockreference
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            string attributevalue = "";
             
            using (Transaction tr = doc.TransactionManager.StartTransaction())
            {
                    BlockReference br = tr.GetObject(id, OpenMode.ForRead) as BlockReference;

                     if (br!= null)
                     {
                         AttributeCollection arColl = br.AttributeCollection;

                         if (arColl != null)
                         {

                             foreach (ObjectId arID in arColl)
                             {

                                 AttributeReference ar = tr.GetObject(arID, OpenMode.ForRead) as AttributeReference;

                                 if (ar.Tag == attributeName)
                                 {
                                     
                                     attributevalue = ar.TextString;
                                 }
                             }
                         } 
                     }
                 
             }
            return attributevalue;
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;public static ObjectIdCollection GetBRids(string blockname)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;

            ObjectIdCollection blockReferenceIDs = new ObjectIdCollection();            

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;

                foreach (ObjectId btrID in bt)
                {
                    BlockTableRecord btr = tr.GetObject(btrID, OpenMode.ForRead) as BlockTableRecord;

                    if (btr != null)
                    {
                        if ( btr.Name == blockname)
                        {
                            blockReferenceIDs = btr.GetBlockReferenceIds(true, true);
                        }
                    }
                }
            }

            return blockReferenceIDs;
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;that will give you some basic ideas of the concepts involved.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please review what Norman has written.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Apr 2017 02:05:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6989623#M32086</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2017-04-02T02:05:49Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6989625#M32087</link>
      <description>&lt;P&gt;No, that is COM API code. use the&lt;STRONG&gt; .net API code&lt;/STRONG&gt; to get your attribute values.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Apr 2017 02:04:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6989625#M32087</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2017-04-02T02:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6999921#M32088</link>
      <description>&lt;P&gt;Hello &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3011731"&gt;@BKSpurgeon&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I am totally confused by your last post.&lt;/P&gt;
&lt;P&gt;I have translated code that you provided to import it in VisualBasic but there are few lines that are not correctly defined. I am not using C# and I have&amp;nbsp; problem to translate code to VB correctly. Problematic code is red colored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    Public Shared Function GetAV(ByVal id As ObjectId, ByVal attributeName As String) As String
        Dim doc As &lt;FONT color="#FF0000"&gt;Document&lt;/FONT&gt; = &lt;FONT color="#FF0000"&gt;Application&lt;/FONT&gt;.DocumentManager.MdiActiveDocument
        Dim ed As &lt;FONT color="#FF0000"&gt;Editor&lt;/FONT&gt; = doc.Editor
        Dim db As Database = doc.Database
        Dim attributevalue As String = ""
        Dim tr As Transaction = doc.TransactionManager.StartTransaction
        Dim br As BlockReference = CType(tr.GetObject(id, OpenMode.ForRead),BlockReference)
        If (Not (br) Is Nothing) Then
            Dim arColl As AttributeCollection = br.AttributeCollection
            If (Not (arColl) Is Nothing) Then
                For Each arID As ObjectId In arColl
                    Dim ar As AttributeReference = CType(tr.GetObject(arID, OpenMode.ForRead),AttributeReference)
                    If (ar.Tag = attributeName) Then
                        attributevalue = ar.TextString
                    End If
                    
                Next
            End If
            
        End If
        
        Return attributevalue
    End Function
Public Shared Function GetBRids(ByVal blockname As String) As ObjectIdCollection
        Dim doc As &lt;FONT color="#FF0000"&gt;Document&lt;/FONT&gt; = &lt;FONT color="#FF0000"&gt;Application&lt;/FONT&gt;.DocumentManager.MdiActiveDocument
        Dim ed As &lt;FONT color="#FF0000"&gt;Editor&lt;/FONT&gt; = doc.Editor
        Dim db As Database = doc.Database
        Dim blockReferenceIDs As ObjectIdCollection = New ObjectIdCollection
        Dim tr As Transaction = db.TransactionManager.StartTransaction
        Dim bt As BlockTable = CType(tr.GetObject(db.BlockTableId, OpenMode.ForRead),BlockTable)
        For Each btrID As ObjectId In bt
            Dim btr As BlockTableRecord = CType(tr.GetObject(btrID, OpenMode.ForRead),BlockTableRecord)
            If (Not (btr) Is Nothing) Then
                If (btr.Name = blockname) Then
                    blockReferenceIDs = btr.GetBlockReferenceIds(true, true)
                End If
                
            End If
            
        Next
        Return blockReferenceIDs
    End Function
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 12:15:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/6999921#M32088</guid>
      <dc:creator>danijel.radenkovic</dc:creator>
      <dc:date>2017-04-06T12:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7000159#M32089</link>
      <description>&lt;P&gt;that's unusual,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in fact all we need is the database. not the editor.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so you can get rid of those lines and replace them with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="pre codeblock hljs bash"&gt;&lt;SPAN class="hljs-string"&gt;Dim db As Autodesk.AutoCAD.DatabaseServices.Database
    db = Application.DocumentManager.MdiActiveDocument.Database&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rgds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 13:35:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7000159#M32089</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2017-04-06T13:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7000222#M32090</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1115624"&gt;@danijel.radenkovic&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;The problem is not between laguages (VB vs C#) which are quite closed as you can see, but between the used API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like you want/need to use the COM/ActiveX API (referencing Autodesk.AutoCAD.Interop.dll and Autodesk.AutoCAD.Interop.Common.dll libraries) and &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3011731"&gt;@BKSpurgeon&lt;/a&gt; gave you a reply using the .NET API (which uses the accoremgd.dll, acdbmgd.dll and acmgd.dll libraries).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please, attentively read &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;'s replies and also these topics from the .NET Developer's Guide : &lt;A href="http://help.autodesk.com/view/ACD/2017/FRA/?guid=GUID-BFFF308E-CC10-4C56-A81E-C15FB300EB70" target="_blank"&gt;COM Interoperability (.NET)&lt;/A&gt; and &lt;A href="http://help.autodesk.com/view/ACD/2017/FRA/?guid=GUID-C8C65D7A-EC3A-42D8-BF02-4B13C2EA1A4B" target="_blank"&gt;Out-of-Process Versus In-Process (.NET)&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 14:01:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7000222#M32090</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-04-06T14:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7000556#M32092</link>
      <description>&lt;P&gt;Hello &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Now I am totally confused by all pieces of codes on this topic. Let's back to the only solution that worked last time. Here is a code which gives me the names of the block in the opened drawing. Please see attached video. Now I would like to get the attributes. How?&lt;/P&gt;
&lt;PRE&gt;Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports AutoCAD
'Imports Autodesk.AutoCAD.DatabaseServices
'Imports Autodesk.AutoCAD.Geometry
'Imports Autodesk.AutoCAD.EditorInput

Imports Microsoft.Office
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Interop.Word
Imports System.IO


Public Class Form1

    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 ss As AcadSelectionSet
        Dim ent As AcadEntity
        Dim blk As AcadBlockReference

        '' Create a selectionset to select everything in drawing (or with filter to select only "INSERT"
        ss = dbxDoc.SelectionSets.Add("test")

        ss.Select(AcSelect.acSelectionSetAll)

        For Each ent In ss
            If TypeOf ent Is AcadBlockReference Then
                blk = ent
                If blk.HasAttributes Then
                    MsgBox("Find block with attribute: " &amp;amp; blk.EffectiveName &amp;amp; ".")
                End If
            End If
        Next
End Sub
End Class&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Apr 2017 15:38:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7000556#M32092</guid>
      <dc:creator>danijel.radenkovic</dc:creator>
      <dc:date>2017-04-06T15:38:59Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7001207#M32093</link>
      <description>&lt;P&gt;You probably missed&amp;nbsp;something from my previous replies. Based on what you show here, let me try one more time:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. You are doing an EXE application to automate AutoCAD (get block information from a drawing opened in AutoCAD. Is that correct? If not, stop reading. We are done.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. As I said previously, in EXE project, you &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;CANNOT USE&lt;/STRONG&gt;&lt;/FONT&gt; AutoCAD .NET API. If you added AutoCAD nET API to your EXE project, it would like not start at all (you would argue your EXE app did run with AutoCAD .NET API added as references as your video shows. Read on.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. As I said, in your project shown in the video, you did add Acad .NET API references and the app runs. Well, you are lucky enough that the EXE app only has very simple code that only uses COM API. If the code touches AutoCAD API, your EXE will crash.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. While BKSpurgeon recommended using AutoCAD .NET API, the condition is you do AutoCAD add-in, not EXE app. Otherwise, anything related to AutoCAD .NET API does not apply to your case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5. You still do not make it clear you want to list all the names of block definitions (with attribute in it), or names of block references that has attribute. Let assume you do know the difference of block definition and block reference, then according to your short "working" code, what you need is name list of block references. Since you mentioned the code ran but get nothing back. That means the drawing may have many block defined in it, but does not have block references (with attribute) are inserted into the drawing, thus no block name is collected. anyway, in my previous reply I have showed the code of getting name list either from block definitions, or from block references. You need to get anything related to AutoCAD .NET API for your EXE app (even I have said the external EXE app is not a good solution in most cases).&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 19:52:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7001207#M32093</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2017-04-06T19:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7001226#M32094</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding the ambiguous reference to Application ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'd guess it's because you will have a Microsoft Office Application and an AutoCAD Application referenced.&lt;/P&gt;
&lt;P&gt;Try using a fully qualified namespace path in your assignments where there may be ambiguity.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 20:00:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7001226#M32094</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2017-04-06T20:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7001411#M32095</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;norman.yuan wrote:&lt;/P&gt;
&lt;P&gt;You probably missed&amp;nbsp;something from my previous replies. Based on what you show here, let me try one more time:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. You are doing an EXE application to automate AutoCAD (get block information from a drawing opened in AutoCAD. Is that correct? If not, stop reading. We are done.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;Yes that's correct. I am trying to iterate with AutoCAD using my exe application.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. As I said previously, in EXE project, you &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;CANNOT USE&lt;/STRONG&gt;&lt;/FONT&gt; AutoCAD .NET API. If you added AutoCAD nET API to your EXE project, it would like not start at all (you would argue your EXE app did run with AutoCAD .NET API added as references as your video shows. Read on.)&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;Clear.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. As I said, in your project shown in the video, you did add Acad .NET API references and the app runs. Well, you are lucky enough that the EXE app only has very simple code that only uses COM API. If the code touches AutoCAD API, your EXE will crash.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;So adding the refferences (AcCoreMgd.dll, AcMgd.dll, AcDbMgd.dll) are reserved just for AutoCAD .NET API (creating .dll which will be loaded using netload and running by command in AutoCAD). Am I right? This is not something that I want, I want to avoid netload loading of .dll. I want to iterate with AutoCAD directly from my .exe application.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;4. While BKSpurgeon recommended using AutoCAD .NET API, the condition is you do AutoCAD add-in, not EXE app. Otherwise, anything related to AutoCAD .NET API does not apply to your case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5. You still do not make it clear you want to list all the names of block definitions (with attribute in it), or names of block references that has attribute. Let assume you do know the difference of block definition and block reference, then according to your short "working" code, what you need is name list of block references. Since you mentioned the code ran but get nothing back. That means the drawing may have many block defined in it, but does not have block references (with attribute) are inserted into the drawing, thus no block name is collected. anyway, in my previous reply I have showed the code of getting name list either from block definitions, or from block references. You need to get anything related to AutoCAD .NET API for your EXE app (even I have said the external EXE app is not a good solution in most cases).&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;I am still confused about the differences between block definition and block refference. Would you like to open please the drawing in the attachment and check the created blocks. What I want is this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;TITLEBLOCK and the attributes are: Circle Block 1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;TITLEBLOCK and the attributes are: Circle Block 2&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;RECTANG_BLOCK and the attributes are: Top_Left text and Bottom_Left text and Bottom_Right text and Top_Right text&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000FF"&gt;This lines from the above are return that I want to get in msgbox, so are they type of block references (which have the attributes) or not?&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 21:08:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7001411#M32095</guid>
      <dc:creator>danijel.radenkovic</dc:creator>
      <dc:date>2017-04-06T21:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7001480#M32096</link>
      <description>&lt;P&gt;If I don't misundertand what you're trying to do, for each selected attributed block, you have to iterate through its attribute collection.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have a look at the &lt;A href="http://help.autodesk.com/view/ACD/2017/FRA/?guid=GUID-3E8E1756-F45D-4CCE-838B-00FBC0374278" target="_blank"&gt;&lt;STRONG&gt;GetAttributes&lt;/STRONG&gt;&lt;/A&gt; COM/ActiveX method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure about VB syntax.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;        For Each ent In ss
            If TypeOf ent Is AcadBlockReference Then
                blk = ent
                If blk.HasAttributes Then
		    Dim text As String = "Find block with attribute: " &amp;amp; blk.EffectiveName &amp;amp; "."
		    For Each att As AttributeReference In blk.GetAttributes()
			text = text &amp;amp; vbCr &amp;amp; att.TagString &amp;amp; ": " &amp;amp; att.TextString
		    Next
                    MsgBox(text)
                End If
            End If
        Next&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Apr 2017 21:40:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7001480#M32096</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-04-06T21:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Get into the blocks and return block names and attributes</title>
      <link>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7001625#M32097</link>
      <description>&lt;P&gt;My apologies seems that i have confused you. anything that my learned colleagues norman and Gilles is very good to read. seeing you dont want to netload use the COM API so the above c# code i provided (which you translated) needs to be scrapped.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i've written above a basic summary of the difference between a block definition and a block reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is something further which might help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;difference between block reference and definition&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Imagine you wrote&amp;nbsp;a really long book about the meaning of life - and that you wanted to distribute it to all your friends. Rather than carry around 10 paper copies of the book (which is 5000 pages long) in your bag - remember carrying all that weight is difficult and it's heavy - it's much more efficient for you to have simply one copy of your essay &lt;EM&gt;online&lt;/EM&gt; and to direct people to go to read your essay online rather than giving them a physical paper copy. that way there is only&amp;nbsp;&lt;STRONG&gt;one&amp;nbsp;definition&amp;nbsp;&lt;/STRONG&gt;of your book but&amp;nbsp;&lt;EM&gt;many&amp;nbsp;&lt;STRONG&gt;references&amp;nbsp;&lt;/STRONG&gt;&lt;/EM&gt;to your book.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Supposing you wanted your mother to read the book but you wanted to change is slightly so that she would understand it better? No problems. Use the same definition, but add any changes to the web link &lt;EM&gt;reference &lt;/EM&gt; that you gave her. Most of the book remains the same. so you still refer to the online version, but the weblink shows a modified version of the book.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;think of it along those lines and i hope it helps.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2017 23:11:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/get-into-the-blocks-and-return-block-names-and-attributes/m-p/7001625#M32097</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2017-04-06T23:11:07Z</dc:date>
    </item>
  </channel>
</rss>

