<?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: How get the original block name from a Dynamic block in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-get-the-original-block-name-from-a-dynamic-block/m-p/7118384#M31220</link>
    <description>&lt;P&gt;Thanks I figured this out and created an extension method:&lt;/P&gt;&lt;PRE&gt;public static string EffectiveName(this BlockReference block)
{
    if (block == null)
        throw new ArgumentNullException(nameof(block));

    if(block.DynamicBlockTableRecord.Database.TransactionManager.TopTransaction == null)
        throw new Runtime.Exception(ErrorStatus.NoActiveTransactions);

    return ((BlockTableRecord)block.DynamicBlockTableRecord.GetObject(OpenMode.ForRead)).Name;
}&lt;/PRE&gt;</description>
    <pubDate>Wed, 31 May 2017 00:54:11 GMT</pubDate>
    <dc:creator>oneMSN</dc:creator>
    <dc:date>2017-05-31T00:54:11Z</dc:date>
    <item>
      <title>How get the original block name from a Dynamic block</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-get-the-original-block-name-from-a-dynamic-block/m-p/7118181#M31218</link>
      <description>&lt;P&gt;Experimenting with dynamic blocks and I discovered an issue that has me stumped.&lt;BR /&gt;&lt;BR /&gt;My code relies on identifying the type of block I am dealing with by looking at the BlockReference.Name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works great for standard/regular blocks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought I would test against a dynamic block, and discovered when one of the dynamic elements is changed AutoCAD's slight of hand replaces the original block with a clone but with a different Name value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for example say I have a block named "MY_BLOCK"&amp;nbsp; after I adjust any of it's dynamic elements, If I then inspect the adjusted block I find that the Block Name is now "*U22"&amp;nbsp; and no longer "MY_BLOCK"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to get the Original Block Name back from this new clone?&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 22:03:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-get-the-original-block-name-from-a-dynamic-block/m-p/7118181#M31218</guid>
      <dc:creator>oneMSN</dc:creator>
      <dc:date>2017-05-30T22:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: How get the original block name from a Dynamic block</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-get-the-original-block-name-from-a-dynamic-block/m-p/7118218#M31219</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get it from the BlockReference.DynamicBlockTableRecord.Name:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;string name = blockRef.IsDynamicBlock ?
    ((BlockTableRecord)blockRef.DynamicBlockTableRecord.GetObject(OpenMode.ForRead)).Name :
    blockRef.Name;&lt;/PRE&gt;</description>
      <pubDate>Tue, 30 May 2017 22:28:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-get-the-original-block-name-from-a-dynamic-block/m-p/7118218#M31219</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2017-05-30T22:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: How get the original block name from a Dynamic block</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-get-the-original-block-name-from-a-dynamic-block/m-p/7118384#M31220</link>
      <description>&lt;P&gt;Thanks I figured this out and created an extension method:&lt;/P&gt;&lt;PRE&gt;public static string EffectiveName(this BlockReference block)
{
    if (block == null)
        throw new ArgumentNullException(nameof(block));

    if(block.DynamicBlockTableRecord.Database.TransactionManager.TopTransaction == null)
        throw new Runtime.Exception(ErrorStatus.NoActiveTransactions);

    return ((BlockTableRecord)block.DynamicBlockTableRecord.GetObject(OpenMode.ForRead)).Name;
}&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 May 2017 00:54:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-get-the-original-block-name-from-a-dynamic-block/m-p/7118384#M31220</guid>
      <dc:creator>oneMSN</dc:creator>
      <dc:date>2017-05-31T00:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: How get the original block name from a Dynamic block</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-get-the-original-block-name-from-a-dynamic-block/m-p/12013251#M31221</link>
      <description>&lt;P&gt;Do you know best way to can get with AutoCAD Interop ?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 00:49:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-get-the-original-block-name-from-a-dynamic-block/m-p/12013251#M31221</guid>
      <dc:creator>Chuong.Ho</dc:creator>
      <dc:date>2023-06-06T00:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: How get the original block name from a Dynamic block</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-get-the-original-block-name-from-a-dynamic-block/m-p/12013451#M31222</link>
      <description>&lt;P&gt;It seems your question has nothing to do with the topic of this thread. You really should post your question in a new discussion thread.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, it is really a vague question: what does "to get AutoCAD interop" mean? Do you mean to use AutoCAD COM API in your AutoCAD .NET plugin project?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is really necessary to use COM API in the .NET API project, you can simply add references to COM API interop assembly/assemblies, then off you go. Better yet, if you only need very few COM API calls, you might want to use late binding (dynamic type in C#), no need to add references to COM API interop and your code is likely work OK with multiple AutoCAD version, as opposed to be tied to certain AutoCAD version, if you do add reference to COM API interop assembly to your project.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 04:00:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-get-the-original-block-name-from-a-dynamic-block/m-p/12013451#M31222</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-06-06T04:00:44Z</dc:date>
    </item>
  </channel>
</rss>

