<?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: Iterating through a dynamic block reference. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12573104#M5404</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12961036"&gt;@ShricharanaB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Oh!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I don't need to use condition here to access the proper block table record at all! I can just get the blockRef.BlockTableRecord, doesn't matter if the block is dynamic, anonymous or static, it'll return the correct btr.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes.&lt;/P&gt;
&lt;P&gt;When you modify some dynamic property of a dynamic block reference, AutoCAD automatically creates a new block definition which reflect the modification (AnonymousBlockTableRecord or BlockTableRecord properties) and keeps a link to the original dynamic block definition (DynamicBlockTableRecord property).&lt;/P&gt;
&lt;P&gt;So, you should not use the AnonymousBlockTableRecord as you did, even with a dynamic block, because it may be null if none dynamic property of the block reference have been modified.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In case of a static block:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;AnonymousBlockTableRecord == null&lt;/LI&gt;
&lt;LI&gt;DynamicBlockTableRecord == BlockTableRecord&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;In case of a non modified dynamic block:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;AnonymousBlockTableRecord == null&lt;/LI&gt;
&lt;LI&gt;DynamicBlockTableRecord == BlockTableRecord (original dynamic block definition)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;In case of a dynamicly modified dynamic block:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;AnonymousBlockTableRecord == BlockTableRecord (modified dynamic block definition)&lt;/LI&gt;
&lt;LI&gt;DynamicBlockTableRecord (original block definition)&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Wed, 21 Feb 2024 09:14:43 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2024-02-21T09:14:43Z</dc:date>
    <item>
      <title>Iterating through a dynamic block reference.</title>
      <link>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12571243#M5399</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have two dynamic blocks DB1 and DB2. DB2 is nested inside DB1. An array driven by a distance parameter has DB2 block as reference.&lt;/P&gt;&lt;P&gt;I'm trying to iterate through DB1 to find all the references of DB2 in it when the distance is changed. I'm using below code to get the dynamic block table record. However, it only returns one reference of DB2 even if the array has added other instances of DB2 as well.&lt;/P&gt;&lt;P&gt;What am I missing here?&lt;/P&gt;&lt;P&gt;How can I get reference of all the instances of DB2 in DB1?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;BlockTableRecord btr = blockRef.IsDynamicBlock ?
    (BlockTableRecord)trans.GetObject(blockRef.DynamicBlockTableRecord, OpenMode.ForRead):                        
    (BlockTableRecord)trans.GetObject(blockRef.BlockTableRecord, OpenMode.ForRead);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ShricharanaB_1-1708435605221.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1328168i18466A6D6C7B013E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ShricharanaB_1-1708435605221.png" alt="ShricharanaB_1-1708435605221.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help.&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>Tue, 20 Feb 2024 13:28:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12571243#M5399</guid>
      <dc:creator>ShricharanaB</dc:creator>
      <dc:date>2024-02-20T13:28:30Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through a dynamic block reference.</title>
      <link>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12571570#M5400</link>
      <description>&lt;P&gt;Dynamic block references can be represented by anonymous blocks, when changes to the dynamic block reference requires a different/distinct graphical representation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have to access the definition of the &lt;EM&gt;anonymous block reference&lt;/EM&gt; (which is what gets inserted), not the dynamic block's definition (which is what the code you posted does). You use the BlockTableRecord property to get the anonymous block's definition.&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>Tue, 20 Feb 2024 16:00:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12571570#M5400</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-02-20T16:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through a dynamic block reference.</title>
      <link>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12572824#M5401</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for pointing it out.&lt;/P&gt;&lt;P&gt;I see where I did wrong. I've corrected the code as below and its working properly.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;BlockTableRecord btr = blockRef.IsDynamicBlock ?
    (BlockTableRecord)trans.GetObject(blockRef.AnonymousBlockTableRecord, OpenMode.ForRead):                       
    (BlockTableRecord)trans.GetObject(blockRef.BlockTableRecord, OpenMode.ForRead);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 06:00:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12572824#M5401</guid>
      <dc:creator>ShricharanaB</dc:creator>
      <dc:date>2024-02-21T06:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through a dynamic block reference.</title>
      <link>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12572915#M5402</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12961036"&gt;@ShricharanaB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much for pointing it out.&lt;/P&gt;
&lt;P&gt;I see where I did wrong. I've corrected the code as below and its working properly.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;BlockTableRecord btr = blockRef.IsDynamicBlock ?
    (BlockTableRecord)trans.GetObject(blockRef.AnonymousBlockTableRecord, OpenMode.ForRead):                       
    (BlockTableRecord)trans.GetObject(blockRef.BlockTableRecord, OpenMode.ForRead);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you again!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In case of a dynamic block reference, the BlockReference.AnonymousBlockTableRecord and BlockReference.BlockTableRecord properties have the same value: the dynamicly modified BlockTableRecord. The BlockReference.DynamicBlockTableRecord property value is the original block definition.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="_gile_0-1708499784676.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1328542i04C2A0EFDBCA447F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="_gile_0-1708499784676.png" alt="_gile_0-1708499784676.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/gileCAD/Gile.Inspector" target="_blank" rel="noopener"&gt;Inspector&lt;/A&gt; plugin available on Github.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 07:19:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12572915#M5402</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-02-21T07:19:22Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through a dynamic block reference.</title>
      <link>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12573044#M5403</link>
      <description>&lt;P&gt;Oh!&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I don't need to use condition here to access the proper block table record at all! I can just get the blockRef.BlockTableRecord, doesn't matter if the block is dynamic, anonymous or static, it'll return the correct btr.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/109424"&gt;@_gile&lt;/a&gt;&amp;nbsp;. Much appreciated.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 08:44:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12573044#M5403</guid>
      <dc:creator>ShricharanaB</dc:creator>
      <dc:date>2024-02-21T08:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: Iterating through a dynamic block reference.</title>
      <link>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12573104#M5404</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/12961036"&gt;@ShricharanaB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Oh!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I don't need to use condition here to access the proper block table record at all! I can just get the blockRef.BlockTableRecord, doesn't matter if the block is dynamic, anonymous or static, it'll return the correct btr.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes.&lt;/P&gt;
&lt;P&gt;When you modify some dynamic property of a dynamic block reference, AutoCAD automatically creates a new block definition which reflect the modification (AnonymousBlockTableRecord or BlockTableRecord properties) and keeps a link to the original dynamic block definition (DynamicBlockTableRecord property).&lt;/P&gt;
&lt;P&gt;So, you should not use the AnonymousBlockTableRecord as you did, even with a dynamic block, because it may be null if none dynamic property of the block reference have been modified.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In case of a static block:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;AnonymousBlockTableRecord == null&lt;/LI&gt;
&lt;LI&gt;DynamicBlockTableRecord == BlockTableRecord&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;In case of a non modified dynamic block:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;AnonymousBlockTableRecord == null&lt;/LI&gt;
&lt;LI&gt;DynamicBlockTableRecord == BlockTableRecord (original dynamic block definition)&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;In case of a dynamicly modified dynamic block:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;AnonymousBlockTableRecord == BlockTableRecord (modified dynamic block definition)&lt;/LI&gt;
&lt;LI&gt;DynamicBlockTableRecord (original block definition)&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 21 Feb 2024 09:14:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/iterating-through-a-dynamic-block-reference/m-p/12573104#M5404</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2024-02-21T09:14:43Z</dc:date>
    </item>
  </channel>
</rss>

