<?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 BLOCK SELECTION SET QUESTION -- Attribute Retrieval in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/block-selection-set-question-attribute-retrieval/m-p/2139461#M76069</link>
    <description>Hi &lt;BR /&gt;
I am trying to accomplish something, I think is relatively simple. I would like to select all the blocks in a DWG file and loop through its attributes where I will load some information into them. I had something that was working, but for some reason it is not "universal" enough as some drawings that ran through it completely ignore the blocks. Therefore, I think I am definitely doing something wrong. &lt;BR /&gt;
&lt;BR /&gt;
Here is what I have:&lt;BR /&gt;
&lt;BR /&gt;
gbl_app.Documents.Open(strfile, 0, 0);&lt;BR /&gt;
AcadDocument doc = gbl_app.ActiveDocument;&lt;BR /&gt;
&lt;BR /&gt;
foreach (AcadBlock blk in doc.Blocks)&lt;BR /&gt;
{&lt;BR /&gt;
try&lt;BR /&gt;
{&lt;BR /&gt;
        foreach (AcadBlockReference blkref in blk)&lt;BR /&gt;
        {&lt;BR /&gt;
               if (blkref.HasAttributes == true)&lt;BR /&gt;
                                {&lt;BR /&gt;
                                    Object[] OBJECT_ATT = (Object[])blkref.GetAttributes();&lt;BR /&gt;
&lt;BR /&gt;
                                    foreach (Object objAttr in OBJECT_ATT)&lt;BR /&gt;
                                    {&lt;BR /&gt;
                                        AcadAttributeReference attref = (AcadAttributeReference)objAttr;&lt;BR /&gt;
&lt;BR /&gt;
                                       attref.TextString = "DATA"&lt;BR /&gt;
&lt;BR /&gt;
                                     }&lt;BR /&gt;
}&lt;BR /&gt;
}&lt;BR /&gt;
}&lt;BR /&gt;
}&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
Can anyone give me an example how I can use a Selection Set to just select all the blocks on a drawing so I can loop through their selection set to read/modify block attributes??? &lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
    <pubDate>Sun, 16 Dec 2007 01:20:29 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2007-12-16T01:20:29Z</dc:date>
    <item>
      <title>BLOCK SELECTION SET QUESTION -- Attribute Retrieval</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-selection-set-question-attribute-retrieval/m-p/2139461#M76069</link>
      <description>Hi &lt;BR /&gt;
I am trying to accomplish something, I think is relatively simple. I would like to select all the blocks in a DWG file and loop through its attributes where I will load some information into them. I had something that was working, but for some reason it is not "universal" enough as some drawings that ran through it completely ignore the blocks. Therefore, I think I am definitely doing something wrong. &lt;BR /&gt;
&lt;BR /&gt;
Here is what I have:&lt;BR /&gt;
&lt;BR /&gt;
gbl_app.Documents.Open(strfile, 0, 0);&lt;BR /&gt;
AcadDocument doc = gbl_app.ActiveDocument;&lt;BR /&gt;
&lt;BR /&gt;
foreach (AcadBlock blk in doc.Blocks)&lt;BR /&gt;
{&lt;BR /&gt;
try&lt;BR /&gt;
{&lt;BR /&gt;
        foreach (AcadBlockReference blkref in blk)&lt;BR /&gt;
        {&lt;BR /&gt;
               if (blkref.HasAttributes == true)&lt;BR /&gt;
                                {&lt;BR /&gt;
                                    Object[] OBJECT_ATT = (Object[])blkref.GetAttributes();&lt;BR /&gt;
&lt;BR /&gt;
                                    foreach (Object objAttr in OBJECT_ATT)&lt;BR /&gt;
                                    {&lt;BR /&gt;
                                        AcadAttributeReference attref = (AcadAttributeReference)objAttr;&lt;BR /&gt;
&lt;BR /&gt;
                                       attref.TextString = "DATA"&lt;BR /&gt;
&lt;BR /&gt;
                                     }&lt;BR /&gt;
}&lt;BR /&gt;
}&lt;BR /&gt;
}&lt;BR /&gt;
}&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
Can anyone give me an example how I can use a Selection Set to just select all the blocks on a drawing so I can loop through their selection set to read/modify block attributes??? &lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Sun, 16 Dec 2007 01:20:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-selection-set-question-attribute-retrieval/m-p/2139461#M76069</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-12-16T01:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: BLOCK SELECTION SET QUESTION -- Attribute Retrieval</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-selection-set-question-attribute-retrieval/m-p/2139462#M76070</link>
      <description>Oh yes, some more information. I am developing my application using C# .NET through the AutoCAD COM interface. Thanks!</description>
      <pubDate>Sun, 16 Dec 2007 01:23:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-selection-set-question-attribute-retrieval/m-p/2139462#M76070</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2007-12-16T01:23:19Z</dc:date>
    </item>
  </channel>
</rss>

