<?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: Keeping track of Dynamic Blocks in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306839#M73968</link>
    <description>Thank you, Tony.</description>
    <pubDate>Fri, 25 Jul 2008 07:39:42 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2008-07-25T07:39:42Z</dc:date>
    <item>
      <title>Keeping track of Dynamic Blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306837#M73966</link>
      <description>I am trying to write a program in VB.NET in which I search for a specific dynamic block in an already existing drawing. The problem I'm having is that when I search for the block name I get the Anonymous name (ie *Uxx). How can i find the reference to the original block name of the dynamic blocks?</description>
      <pubDate>Thu, 24 Jul 2008 14:46:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306837#M73966</guid>
      <dc:creator>ScottSpringfield</dc:creator>
      <dc:date>2008-07-24T14:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping track of Dynamic Blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306838#M73967</link>
      <description>You need to be more specific as to what you mean by 'search for'&lt;BR /&gt;
&lt;BR /&gt;
Do you mean selection set filtering, or manually examining every block reference?&lt;BR /&gt;
&lt;BR /&gt;
One way to find all references to a dynamic block, is to examine all anonymous block references, and compare the DynamicBlockTableRecord property of each to the ObjectId of the dynamic block definition.&lt;BR /&gt;
&lt;BR /&gt;
Another way is to open the dynamic block (BlockTableRecord) and call its GetAnonymousBlockIds() function. Then, loop through the result and open each anonymous block table record and call its GetBlockReferenceIds() method to get the references to each anonymous block, like this:&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
&lt;BR /&gt;
public static class BlockHelper&lt;BR /&gt;
{&lt;BR /&gt;
&lt;BR /&gt;
   /// Pass ObjectId of a block (BlockTableRecord), and this &lt;BR /&gt;
   /// returns the ObjectIds of all references to the block,&lt;BR /&gt;
   /// including all dynamic block references. This method&lt;BR /&gt;
   /// provides a uniform way to get the ids of all blockrefs,&lt;BR /&gt;
   /// regardless of whether the block is dynamic or not.&lt;BR /&gt;
&lt;BR /&gt;
   static ObjectIdCollection GetBlockReferenceIds( ObjectId btrId )&lt;BR /&gt;
   {&lt;BR /&gt;
      if( btrId.IsNull )&lt;BR /&gt;
         throw new ArgumentException( "null object id" );&lt;BR /&gt;
      ObjectIdCollection result = new ObjectIdCollection();&lt;BR /&gt;
      using( Transaction trans = btrId.Database.TransactionManager.StartTransaction() )&lt;BR /&gt;
      {&lt;BR /&gt;
         try&lt;BR /&gt;
         {&lt;BR /&gt;
            /// open the BlockTableRecord: &lt;BR /&gt;
&lt;BR /&gt;
            BlockTableRecord btr = trans.GetObject( btrId, OpenMode.ForRead ) as BlockTableRecord;&lt;BR /&gt;
            if( btr != null )&lt;BR /&gt;
            {&lt;BR /&gt;
               // Add the ids of all references to the BTR. Some dynamic blocks may&lt;BR /&gt;
               // reference the dynamic block directly rather than an anonymous block,&lt;BR /&gt;
               // so this will get those as well:&lt;BR /&gt;
&lt;BR /&gt;
               ObjectIdCollection blockRefIds = btr.GetBlockReferenceIds( true, false );&lt;BR /&gt;
               if( blockRefIds != null )&lt;BR /&gt;
               {&lt;BR /&gt;
                  foreach( ObjectId id in blockRefIds )&lt;BR /&gt;
                     result.Add( id );&lt;BR /&gt;
               }&lt;BR /&gt;
&lt;BR /&gt;
               // if this is not a dynamic block, we're done:&lt;BR /&gt;
&lt;BR /&gt;
               if( !btr.IsDynamicBlock )  &lt;BR /&gt;
                  return result;&lt;BR /&gt;
&lt;BR /&gt;
               // Get the ids of all anonymous block table records for the dynamic block&lt;BR /&gt;
&lt;BR /&gt;
               ObjectIdCollection anonBtrIds = btr.GetAnonymousBlockIds();&lt;BR /&gt;
               if( anonBtrIds != null )&lt;BR /&gt;
               {&lt;BR /&gt;
                  foreach( ObjectId anonBtrId in anonBtrIds )&lt;BR /&gt;
                  {&lt;BR /&gt;
                     // get all references to each anonymous block:&lt;BR /&gt;
&lt;BR /&gt;
                     BlockTableRecord rec = trans.GetObject( anonBtrId, OpenMode.ForRead ) as BlockTableRecord;&lt;BR /&gt;
                     if( rec != null )&lt;BR /&gt;
                     {&lt;BR /&gt;
                        blockRefIds = rec.GetBlockReferenceIds( false, true );&lt;BR /&gt;
                        if( blockRefIds != null )&lt;BR /&gt;
                        {&lt;BR /&gt;
                           foreach( ObjectId id in blockRefIds )&lt;BR /&gt;
                              result.Add( id );&lt;BR /&gt;
                        }&lt;BR /&gt;
                     }&lt;BR /&gt;
                  }&lt;BR /&gt;
               }&lt;BR /&gt;
            }&lt;BR /&gt;
         }&lt;BR /&gt;
         finally&lt;BR /&gt;
         {&lt;BR /&gt;
            trans.Commit();&lt;BR /&gt;
         }&lt;BR /&gt;
      }&lt;BR /&gt;
      return result;&lt;BR /&gt;
   }&lt;BR /&gt;
&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2009&lt;BR /&gt;
Supporting AutoCAD 2000 through 2009&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Introducing AcadXTabs 2010:&lt;BR /&gt;
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm&lt;BR /&gt;
&lt;BR /&gt;
&lt;SIANEL&gt; wrote in message news:5989553@discussion.autodesk.com...&lt;BR /&gt;
I am trying to write a program in VB.NET in which I search for a specific dynamic block in an already existing drawing. The problem I'm having is that when I search for the block name I get the Anonymous name (ie *Uxx). How can i find the reference to the original block name of the dynamic blocks?&lt;/SIANEL&gt;</description>
      <pubDate>Thu, 24 Jul 2008 21:16:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306838#M73967</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-07-24T21:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping track of Dynamic Blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306839#M73968</link>
      <description>Thank you, Tony.</description>
      <pubDate>Fri, 25 Jul 2008 07:39:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306839#M73968</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-07-25T07:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping track of Dynamic Blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306840#M73969</link>
      <description>Hi Tony,&lt;BR /&gt;
I get this error when I try to compyle this code.&lt;BR /&gt;
&lt;BR /&gt;
'Autodesk.AutoCAD.DatabaseServices.BlockTableRecord' does not contain a &lt;BR /&gt;
definition for 'GetAnonymousBlockIds' and no extension method &lt;BR /&gt;
'GetAnonymousBlockIds' accepting a first argument of type &lt;BR /&gt;
'Autodesk.AutoCAD.DatabaseServices.BlockTableRecord' could be found (are you &lt;BR /&gt;
missing a using directive or an assembly reference?)&lt;BR /&gt;
&lt;BR /&gt;
Do you have any idea?&lt;BR /&gt;
&lt;BR /&gt;
Roland</description>
      <pubDate>Fri, 25 Jul 2008 07:50:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306840#M73969</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-07-25T07:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping track of Dynamic Blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306841#M73970</link>
      <description>I have a got the same exeption with&lt;BR /&gt;
'GetAnonymousBlockIds' &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;BR /&gt;
&lt;BR /&gt;
~'J'~</description>
      <pubDate>Fri, 25 Jul 2008 08:37:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306841#M73970</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-07-25T08:37:34Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping track of Dynamic Blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306842#M73971</link>
      <description>Oops. &lt;BR /&gt;
&lt;BR /&gt;
Looks like GetAnonymousBlockIds() is new to AutoCAD 2009, which you're obviously not using.&lt;BR /&gt;
&lt;BR /&gt;
You have to take the other route, gathering all block references, and then looking each one's DynamicBlockTableRecord property.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2009&lt;BR /&gt;
Supporting AutoCAD 2000 through 2009&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Introducing AcadXTabs 2010:&lt;BR /&gt;
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm&lt;BR /&gt;
&lt;BR /&gt;
"Roland Feletic" &lt;FELETIC_AT_PAUSER_DOT_AT&gt; wrote in message news:5990363@discussion.autodesk.com...&lt;BR /&gt;
Hi Tony,&lt;BR /&gt;
I get this error when I try to compyle this code.&lt;BR /&gt;
&lt;BR /&gt;
'Autodesk.AutoCAD.DatabaseServices.BlockTableRecord' does not contain a &lt;BR /&gt;
definition for 'GetAnonymousBlockIds' and no extension method &lt;BR /&gt;
'GetAnonymousBlockIds' accepting a first argument of type &lt;BR /&gt;
'Autodesk.AutoCAD.DatabaseServices.BlockTableRecord' could be found (are you &lt;BR /&gt;
missing a using directive or an assembly reference?)&lt;BR /&gt;
&lt;BR /&gt;
Do you have any idea?&lt;BR /&gt;
&lt;BR /&gt;
Roland&lt;/FELETIC_AT_PAUSER_DOT_AT&gt;</description>
      <pubDate>Fri, 25 Jul 2008 20:28:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306842#M73971</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-07-25T20:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Keeping track of Dynamic Blocks</title>
      <link>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306843#M73972</link>
      <description>Sorry, it was my fault. Now I've seen that i had the wrong acdbmgd.dll and &lt;BR /&gt;
acmgd.dll. Changed it to 2009 and now it works. Thank you again.&lt;BR /&gt;
&lt;BR /&gt;
"Tony Tanzillo" &lt;TONY.TANZILLO&gt; schrieb im Newsbeitrag &lt;BR /&gt;
news:5991086@discussion.autodesk.com...&lt;BR /&gt;
Oops.&lt;BR /&gt;
&lt;BR /&gt;
Looks like GetAnonymousBlockIds() is new to AutoCAD 2009, which you're &lt;BR /&gt;
obviously not using.&lt;BR /&gt;
&lt;BR /&gt;
You have to take the other route, gathering all block references, and then &lt;BR /&gt;
looking each one's DynamicBlockTableRecord property.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2009&lt;BR /&gt;
Supporting AutoCAD 2000 through 2009&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Introducing AcadXTabs 2010:&lt;BR /&gt;
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm&lt;BR /&gt;
&lt;BR /&gt;
"Roland Feletic" &lt;FELETIC_AT_PAUSER_DOT_AT&gt; wrote in message &lt;BR /&gt;
news:5990363@discussion.autodesk.com...&lt;BR /&gt;
Hi Tony,&lt;BR /&gt;
I get this error when I try to compyle this code.&lt;BR /&gt;
&lt;BR /&gt;
'Autodesk.AutoCAD.DatabaseServices.BlockTableRecord' does not contain a&lt;BR /&gt;
definition for 'GetAnonymousBlockIds' and no extension method&lt;BR /&gt;
'GetAnonymousBlockIds' accepting a first argument of type&lt;BR /&gt;
'Autodesk.AutoCAD.DatabaseServices.BlockTableRecord' could be found (are you&lt;BR /&gt;
missing a using directive or an assembly reference?)&lt;BR /&gt;
&lt;BR /&gt;
Do you have any idea?&lt;BR /&gt;
&lt;BR /&gt;
Roland&lt;/FELETIC_AT_PAUSER_DOT_AT&gt;&lt;/TONY.TANZILLO&gt;</description>
      <pubDate>Mon, 28 Jul 2008 07:25:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/keeping-track-of-dynamic-blocks/m-p/2306843#M73972</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2008-07-28T07:25:36Z</dc:date>
    </item>
  </channel>
</rss>

