<?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: Block-Functions (Select, Explode, etc.) in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3418273#M56264</link>
    <description>&lt;P&gt;My examiners don't know anything about AutoCAD, it is the programming part which is important. And because of that, I have to do a lot more exception handling, they understand such things.&amp;nbsp;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt; work for tomorrow...&amp;nbsp;&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the great support!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greets&lt;/P&gt;&lt;P&gt;Klaus&lt;/P&gt;</description>
    <pubDate>Tue, 17 Apr 2012 22:33:38 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-04-17T22:33:38Z</dc:date>
    <item>
      <title>Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3413951#M56242</link>
      <description>&lt;P&gt;Hi community!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a C#-WPF-Application. In this application there is a list of blocks in my drawing. When I click one of these blocks in the listbox I have several button-functions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;One of them:&lt;/P&gt;&lt;P&gt;Select the in the list selected block in the drawing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another:&lt;/P&gt;&lt;P&gt;Explode the in the list selected block.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found several topics with Selection, but none of them worked for me. I'm looking for a selection via ObjectId or blockname of a single block, in the most cases the selectionfilter needs an array(?).&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I'm absolutly helpless with block-explosion.&amp;nbsp;&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://forums.autodesk.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm really new to Autocad and C#-Addin-programming.&amp;nbsp;&lt;img id="smileyindifferent" class="emoticon emoticon-smileyindifferent" src="https://forums.autodesk.com/i/smilies/16x16_smiley-indifferent.png" alt="Smiley Indifferent" title="Smiley Indifferent" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;Greets&lt;/P&gt;&lt;P&gt;Klaus&lt;/P&gt;</description>
      <pubDate>Sun, 15 Apr 2012 09:16:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3413951#M56242</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-15T09:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3415481#M56243</link>
      <description>&lt;P&gt;This blog post explains the selection filter mechanism&lt;/P&gt;&lt;P&gt;&lt;A target="_self" href="http://through-the-interface.typepad.com/through_the_interface/2008/07/conditional-sel.html"&gt;http://through-the-interface.typepad.com/through_the_interface/2008/07/conditional-sel.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What you basically need for the selection filter (by blockname)&amp;nbsp;is:&lt;/P&gt;&lt;PRE&gt;TypedValue[] SSfilter = {
	new TypedValue(0, "INSERT"),
	new TypedValue(2, "BLOCKNAME")
};&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;If you have objectid(s) and want them to be selected in the editor, you use editor.SetImpliedSelection(objectid())&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Assuming you are using the managed API, there are two ways to explode a BlockReference, one is the Explode method inherited from entity.&amp;nbsp; You pass in a DbObjectCollection, and AutoCAD fills the collection with the entities generated from the explode.&amp;nbsp; You are then responsible for either adding them to the database, or disposing of them when you are done, depending on your needs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The other is BlockReference.ExplodeToOwnerSpace().&amp;nbsp; That one automatically appends the generated entities to the parent of the block reference.&amp;nbsp; This could be the Model space, or a paper space layout, or even another block if the block was nested.&amp;nbsp; The Block must be uniformly scaled in both methods.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 16:52:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3415481#M56243</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2012-04-16T16:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3415673#M56244</link>
      <description>&lt;P&gt;Okay,&lt;STRONG&gt; first problem: Selection:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the Selection like this:&lt;/P&gt;&lt;PRE&gt;public void selectBlock(string blockName)
{
   BlockTableRecord btr = null;
   Editor ed = doc.Editor;
   using (tr = db.TransactionManager.StartTransaction())
   {
      BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForWrite);
      foreach (ObjectId objId in bt)
      {
         btr = (BlockTableRecord)tr.GetObject(objId, OpenMode.ForWrite);

         if (blockName == btr.Name)
         {
            TypedValue[] tvs = new TypedValue[] {
               new TypedValue(
                  (int)DxfCode.Operator,
                  "&amp;lt;or"
               ),
               new TypedValue (
                  (int)DxfCode.BlockName,
                  btr.Name
               ),
               new TypedValue(
                  (int)DxfCode.Operator,
                  "or&amp;gt;"
               )
            };

            SelectionFilter sf = new SelectionFilter(tvs);
            PromptSelectionResult psr = ed.SelectAll(sf);
            ed.WriteMessage("\nFound {0} entit{1}.", psr.Value.Count, (psr.Value.Count == 1 ? "y" : "ies"));
         }
      }
   }
}&lt;/PRE&gt;&lt;P&gt;I know, I could simply give the blockName to the DxfCode.BlockName-variable without foreach and so on, but I also tried it with objectId. Hmm, theeditor-message shows up that AutoCAD finds one entity. But this entity isn't selected!?&amp;nbsp;&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://forums.autodesk.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But Kean Walmsley also writes in his blog: "&lt;SPAN&gt;&amp;nbsp;This simply tells you how many entities met the selection criteria - it doesn't leave them selected for use by further commands.".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Okay, now... How do I leave it selected for use by further commands?&amp;nbsp;&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I've also tried the selection like you posted it with :&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;new TypedValue(0, "INSERT"),
new TypedValue(2, blockName)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;If this is, what you've meant, it doesn't work for me either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I didn't get your point with the objectId-selection, my editor wants an array of ObjectIds. Should I create an Array of ObjectIds with the objectid of the block on the first position? &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://forums.autodesk.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;But if I get it working with the blockname, I do not need the selection by objectid. I simply want the easiest way to select the block.&amp;nbsp;&lt;SPAN&gt;&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;__________________________________&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Second problem: Explosion&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My block is a BlockTableRecord. How do I get a BlockReference to work with my BlockTableRecord?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;&lt;P&gt;Klaus&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 18:29:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3415673#M56244</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-16T18:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3416219#M56245</link>
      <description>&lt;P&gt;Well, I've already done all this once, then when I went to post it, the discussion group kicked me out, so here goes again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;First, I think you need to do a little research on the difference between a BlockTableRecord, and a BlockReference.&amp;nbsp; It has been covered on this discussion group so I'm not going to get into here, especially because I have no idea what your experience level with AutoCAD is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kean's comment &lt;EM&gt;"&lt;/EM&gt;&lt;SPAN&gt;&lt;EM&gt;This simply tells you how many entities met the selection criteria - it doesn't leave them selected for use by further commands."&lt;/EM&gt;&amp;nbsp; Means that the entities are not left selected in the editor, there is a selection set created (psr.value)&amp;nbsp;that can be used by code to do other things with the selection, they just don't appear to be selected to the user after function ends.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have worked up these two quick examples of how to get the objects you want and leave them selected in the editor after your command completes.&amp;nbsp; One piece that is not shown here is the the CommandMethod that is called to use this code must have the "CommandFlags.Redraw" set.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public void selectBlock(string blockName)
{
Database db = HostApplicationServices.WorkingDatabase;
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
    try
    {
        BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead, false, true);
        if (bt.Has(blockName))
        {
            ObjectId btrid = bt[blockName];
            if (!btrid.IsEffectivelyErased)
            {
                BlockTableRecord btr = (BlockTableRecord)trans.GetObject(btrid, OpenMode.ForRead, false, true);
                ObjectIdCollection brefIDs = btr.GetBlockReferenceIds(true, false);
                ObjectId[] oids = new ObjectId[brefIDs.Count];
                brefIDs.CopyTo(oids, 0);
                ed.SetImpliedSelection(oids);
            }
        }
        trans.Commit();
    }
    catch (System.Exception ex)
    {
        //
    }
}
}

public void selectBlock2(string blockName)
{
Database db = HostApplicationServices.WorkingDatabase;
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
TypedValue[] tvs = new TypedValue[] {
	new TypedValue(0, "INSERT"),
	new TypedValue(2, blockName)
};
SelectionFilter sf = new SelectionFilter(tvs);
PromptSelectionResult psr = ed.SelectAll(sf);
if (psr.Status == PromptStatus.OK)
{
    ed.SetImpliedSelection(psr.Value.GetObjectIds());
}
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I would use the second method, as it does not require a transaction, but the first method does demonstrate something that may be useful for your Explode problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can not call Explode on a BlockTableRecord.&amp;nbsp; You also can not "Select" them using selection methods or filters.&amp;nbsp; There is no graphical representation of a BlockTableRecord.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So you say you have a BlockTableRecord.&amp;nbsp; If all you want is to find out what is in that BlockTableRecord, you can iterate through it's contents with a For Each of DbObject.&amp;nbsp; I am assuming that is not what you want, and that what you want is to Explode the BlockReferences that point to that BlockTableRecord.&amp;nbsp; The first example above shows how to get the ObjectIds of all BlockReferences that point to a particular BlockTableRecord.&amp;nbsp; You can then use those ObjectIds to open each BlockReference and call .ExplodeToOwnerSpace if you want to duplicate the behavior of the AutoCAD Explode command (I'm not sure if you have to erase the original block, or if the API does it for you, but the API does add each of the resultant entities to the owner of the BlockReference), or you can call .Explode and the use the results of that explode to do whatever it is you need to do (In which case you must add the objects to the database or dispose of them, and if you want the original block to be erased you have to do that yourself).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Give that a shot.&amp;nbsp; I'll see if I can find a good article describing the difference between a BlockTableRecord and a BlockReference.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 23:07:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3416219#M56245</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2012-04-16T23:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3416241#M56246</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/468374"&gt;@chiefbraincloud&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;&amp;nbsp; It has been covered on this discussion group so I'm not going to get into here, especially because I have no idea what your experience level with AutoCAD is.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hmm, well... My AutoCAD-experiences belong to an half-an-hour introduction of a friend of mine.&amp;nbsp;&lt;img id="smileyfrustrated" class="emoticon emoticon-smileyfrustrated" src="https://forums.autodesk.com/i/smilies/16x16_smiley-frustrated.png" alt="Smiley Frustrated" title="Smiley Frustrated" /&gt;&lt;/P&gt;&lt;P&gt;It is a small project for my school leaving examination. I have to make a little plugin for a company, it isn't really bad for them if it is only a prototype.&amp;nbsp;&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks, the Selection works like a charm!&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the explosion like this:&lt;/P&gt;&lt;PRE&gt;public void explodeBlock(string blockName)
{
   Editor ed = doc.Editor;
   using (tr = db.TransactionManager.StartTransaction())
   {
      BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead, false, true);
      if (bt.Has(blockName)) {
         ObjectId btrid = bt[blockName];
         if (!btrid.IsEffectivelyErased) {
            BlockTableRecord btr = (BlockTableRecord)tr.GetObject(btrid, OpenMode.ForRead, false, true);

            ObjectIdCollection brefIds = btr.GetBlockReferenceIds(true, false);
            ObjectId[] oids = new ObjectId[brefIds.Count];
            brefIds.CopyTo(oids, 0);
            foreach (ObjectId objid in brefIds) {
               BlockReference br = (BlockReference)tr.GetObject(objid, OpenMode.ForWrite);
               br.ExplodeToOwnerSpace();
            }
         }
      }
   }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I do not really realize if something has changed, can I check this anywhere?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greets&lt;/P&gt;&lt;P&gt;Klaus&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2012 23:46:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3416241#M56246</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-16T23:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3416255#M56247</link>
      <description>&lt;P&gt;first: these two lines are useless in your function&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ObjectId[] oids = new ObjectId[brefIds.Count];&lt;BR /&gt;brefIds.CopyTo(oids, 0);&lt;/P&gt;&lt;P&gt;Second, I would definitely put the ExplodeToOwnerSpace() method inside a Try/Catch, because if the block has a non-uniform scale (ie. the X, Y, and Z scales are not the same) which is not that uncommon, the ExplodeToOwnerSpace method will fail.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To see the change, try using your selection tool to select all references of a block.&amp;nbsp; Look at the drawing window, and you should see some grips (little colored squares), by default there should be one grip per block (but there is a user setting that would cause more grips to show up).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;then zoom in to where you can see one or more of the blocks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Run your explode tool on the same blockName.&amp;nbsp; Then you can perform two tests. one, try using the mouse and selecting a part of the block you have in your view.&amp;nbsp; If it is exploded, you will now have individual entities (lines, arcs, circles, etc...)&amp;nbsp;instead of multiple entities grouped into a single block, and you will see more than one grip, and the whole block will not be selected, but just the entity or entities&amp;nbsp;you pick.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;test two, try running your select tool again on the same block.&amp;nbsp; If the original blocks were erased when they were exploded, you will get zero selected objects.&amp;nbsp; If not you will have to add a line of code in your for each to erase them manually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically not being able to see a difference should be a good thing (if you aren't getting any errors)&amp;nbsp;but the help docs are not clear about whether the original block is erased by ExplodeToOwnerSpace, so you could have a bunch of new entities created right on top of the old block, but what you really want is a bunch of new entities, and no more old block.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 00:34:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3416255#M56247</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2012-04-17T00:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3416447#M56248</link>
      <description>&lt;P&gt;Hmm for me it does nothing.&amp;nbsp;&lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://forums.autodesk.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt; Not even if i call&lt;/P&gt;&lt;PRE&gt;br.Erase()&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I tried it with the drawing I've got from alfred.neswadba (&lt;A target="_blank" href="http://forums.autodesk.com/t5/NET/Edit-a-Block-via-C/m-p/3366541#M27591"&gt;http://forums.autodesk.com/t5/NET/Edit-a-Block-via-C/m-p/3366541#M27591&lt;/A&gt;), you find it attached. Seems not to work. &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://forums.autodesk.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Oh, the last function I have to implement should copy a block and paste it. For paste there should be a cursor to set the insertpoint for the block (like the usual insert in AutoCAD). How complex would this be? &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://forums.autodesk.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greets&lt;/P&gt;&lt;P&gt;Klaus&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 06:16:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3416447#M56248</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-17T06:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417073#M56249</link>
      <description>&lt;P&gt;See if this is working for you,&lt;/P&gt;&lt;P&gt;tested on A2010 only&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    Public Sub ApplyAttributes(db As Database, tr As Transaction, bref As BlockReference)

        Dim btrec As BlockTableRecord = TryCast(tr.GetObject(bref.BlockTableRecord, OpenMode.ForRead), BlockTableRecord)

        If btrec.HasAttributeDefinitions Then

            Dim atcoll As Autodesk.AutoCAD.DatabaseServices.AttributeCollection = bref.AttributeCollection

            For Each subid As ObjectId In btrec

                Dim ent As Entity = DirectCast(subid.GetObject(OpenMode.ForRead), Entity)

                Dim attDef As AttributeDefinition = TryCast(ent, AttributeDefinition)

                If attDef IsNot Nothing Then

                    Dim attRef As New AttributeReference()

                    attRef.SetDatabaseDefaults()

                    attRef.SetAttributeFromBlock(attDef, bref.BlockTransform)

                    attRef.Position = attDef.Position.TransformBy(bref.BlockTransform)

                    attRef.Tag = attDef.Tag

                    attRef.TextString = attDef.TextString

                    attRef.AdjustAlignment(db)

                    atcoll.AppendAttribute(attRef)

                    tr.AddNewlyCreatedDBObject(attRef, True)

                End If

            Next
        End If
    End Sub
    Public Sub TestInsert()
        Dim blkname As String = "VT_VZ_VZ52_10a_ATT" ''&amp;lt;-- as per as on your drawing
        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim ed As Editor = doc.Editor
        Dim db As Database = doc.Database
        Try
            Using docloc As DocumentLock = doc.LockDocument

                Using tr As Transaction = db.TransactionManager.StartTransaction
                    Dim bt As BlockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead)

                    If Not bt.Has(blkname) Then
                        MsgBox("Block does not exists")
                        Return
                    End If

                    Dim pto As PromptPointOptions = New PromptPointOptions(vbLf + "Pick a block insertion point: ")
                    Dim ptres As PromptPointResult = ed.GetPoint(pto)
                    Dim ipt As Point3d

                    If ptres.Status &amp;lt;&amp;gt; PromptStatus.Cancel Then
                        ipt = ptres.Value
                    End If

                    Dim btr As BlockTableRecord = DirectCast(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite, False), BlockTableRecord)
                    Dim blk As BlockTableRecord = DirectCast(tr.GetObject(bt(blkname), OpenMode.ForRead, False), BlockTableRecord)
                    Dim bref As New BlockReference(ipt, blk.ObjectId)
                    bref.BlockUnit = UnitsValue.Millimeters
                    bref.Rotation = 0
                    bref.ScaleFactors = New Scale3d(1000.0) ''&amp;lt;-- as per as on your drawing
                    btr.AppendEntity(bref)
                    tr.AddNewlyCreatedDBObject(bref, True)
                    ApplyAttributes(db, tr, bref)
                    ed.Regen()
                    tr.Commit()
                End Using
            End Using
        Catch ex As System.Exception
            MsgBox(ex.Message)
        End Try
    End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333399" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 14:28:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417073#M56249</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-04-17T14:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417319#M56250</link>
      <description>&lt;P&gt;Okay, Explosion is working!&amp;nbsp;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just add an tr.Commit() to my function....&amp;nbsp;&lt;img id="smileyembarrassed" class="emoticon emoticon-smileyembarrassed" src="https://forums.autodesk.com/i/smilies/16x16_smiley-embarrassed.png" alt="Smiley Embarassed" title="Smiley Embarassed" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To the insert:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm not very common with VB, so i translated it with &amp;lt;&amp;nbsp;&lt;A target="_self" href="http://www.developerfusion.com/tools/convert/vb-to-csharp/"&gt;Convert C# to VB.NET&lt;/A&gt;&amp;nbsp;&amp;gt;. What I got is (in your TestInsert()-method):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PromptPointOptions pto = new PromptPointOptions(Constants.vbLf + "Pick a block insertion point: ");&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Hmm Constants."anything" doesn't tell me anything, so i've deleted "Constants.", but vbLf is nowhere declared in this method. How do you use it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The second thing:&lt;/P&gt;&lt;PRE&gt;BlockTableRecord blk = (BlockTableRecord)tr.GetObject(bt(blkname), OpenMode.ForRead, false);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;'bt' is a variable but used like a method, can you explain this to me?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And many thanks to chiefbraincloud&amp;nbsp;for your help at Selection &amp;amp; Explosion!&amp;nbsp;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greets&lt;/P&gt;&lt;P&gt;Klaus&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 15:58:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417319#M56250</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-17T15:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417381#M56251</link>
      <description>&lt;P&gt;Oops.&amp;nbsp; I didn't even look to see if you had the .commit in there.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;vbLf is a constant for a line feed character (in Visual Basic), I don't know if C# has a similar set of constants, but I know you can use chr(13).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2nd&amp;nbsp;prob should be square braces instead of parenthesis:&lt;/P&gt;&lt;P&gt;BlockTableRecord blk = (BlockTableRecord)tr.GetObject(bt[blkname], OpenMode.ForRead, false);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I didn't look at Hallex's code other than what you posted as conversion problems.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 16:23:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417381#M56251</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2012-04-17T16:23:39Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417509#M56252</link>
      <description>&lt;P&gt;Sorry, try converted on C# instead&lt;/P&gt;&lt;PRE&gt;        public static void ApplyAttributes(Database db, Transaction tr, BlockReference bref)
        {
            BlockTableRecord btrec = tr.GetObject(bref.BlockTableRecord, OpenMode.ForRead) as BlockTableRecord;

            if (btrec.HasAttributeDefinitions)
            {
                Autodesk.AutoCAD.DatabaseServices.AttributeCollection atcoll = bref.AttributeCollection;

                foreach (ObjectId subid in btrec)
                {
                    Entity ent = (Entity)subid.GetObject(OpenMode.ForRead);

                    AttributeDefinition attDef = ent as AttributeDefinition;

                    if (attDef != null)
                    {

                        AttributeReference attRef = new AttributeReference();

                        attRef.SetDatabaseDefaults();

                        attRef.SetAttributeFromBlock(attDef, bref.BlockTransform);

                        attRef.Position = attDef.Position.TransformBy(bref.BlockTransform);

                        attRef.Tag = attDef.Tag;

                        attRef.TextString = attDef.TextString;

                        attRef.AdjustAlignment(db);

                        atcoll.AppendAttribute(attRef);

                        tr.AddNewlyCreatedDBObject(attRef, true);

                    }
                }
            }
        }
        [CommandMethod("insBlock", CommandFlags.Modal | CommandFlags.UsePickSet)]
        public void TestInsert()
        {
            string blkname = "VT_VZ_VZ52_10a_ATT";
            //'&amp;lt;-- as per as on your drawing
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            try
            {
                using (DocumentLock docloc = doc.LockDocument())
                {

                    using (Transaction tr = db.TransactionManager.StartTransaction())
                    {
                        BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);

                        if (!bt.Has(blkname))
                        {
                            ed.WriteMessage("\nBlock does not exists");
                            return;
                        }

                        PromptPointOptions pto = new PromptPointOptions("\nPick a block insertion point: ");
                        PromptPointResult ptres = ed.GetPoint(pto);
                        Point3d ipt = default(Point3d);

                        if (ptres.Status != PromptStatus.Cancel)
                        {
                            ipt = ptres.Value;
                        }

                        BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite, false);
                        BlockTableRecord blk = (BlockTableRecord)tr.GetObject(bt[blkname], OpenMode.ForRead, false);
                        BlockReference bref = new BlockReference(ipt, blk.ObjectId);
                        bref.BlockUnit = UnitsValue.Millimeters;
                        bref.Rotation = 0;
                        bref.ScaleFactors = new Scale3d(1000.0);
                        //'&amp;lt;-- as per as on your drawing
                        btr.AppendEntity(bref);
                        tr.AddNewlyCreatedDBObject(bref, true);
                        ApplyAttributes(db, tr, bref);
                        ed.Regen();
                        tr.Commit();
                    }
                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(ex.Message);
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333399" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 17:07:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417509#M56252</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-04-17T17:07:08Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417527#M56253</link>
      <description>&lt;P&gt;I forgot all about "\n".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Shame on me.&amp;nbsp; My lisp programming skills are getting too rusty.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 17:15:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417527#M56253</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2012-04-17T17:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417607#M56254</link>
      <description>&lt;P&gt;But you know many other stuffs,&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Oleg&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 17:37:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417607#M56254</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-04-17T17:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417619#M56255</link>
      <description>&lt;P&gt;What about Copy-Paste, just a quick code almost not tested&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        [CommandMethod("copypaste", CommandFlags.Modal | CommandFlags.UsePickSet)]
        public void CopyPaste()
        {

            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            Database db = doc.Database;

            Editor ed = doc.Editor;

            Matrix3d ucs = ed.CurrentUserCoordinateSystem;
            try
            {

                using (Transaction tr = db.TransactionManager.StartTransaction())
                {

                    PromptEntityOptions peo = new PromptEntityOptions("\nSelect a block  &amp;gt;&amp;gt;");

                    peo.SetRejectMessage("\nSelect block only &amp;gt;&amp;gt;");

                    peo.AddAllowedClass(typeof(BlockReference), false);

                    PromptEntityResult res;

                    res = ed.GetEntity(peo);

                    if (res.Status != PromptStatus.OK)

                        return;

                    Entity ent = (Entity)tr.GetObject(res.ObjectId, OpenMode.ForRead);

                    if (ent == null) return;

                    ObjectIdCollection ids = new ObjectIdCollection();

                    ids.Add(ent.ObjectId);

                    ObjectId chkId = ent.ObjectId;

                    BlockReference bref = ent as BlockReference;

                    Point3d pt = Point3d.Origin;

                    BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);

                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);

                    PromptPointOptions pto = new PromptPointOptions("\nPick a block insertion point: ");

                    PromptPointResult ptres = ed.GetPoint(pto);

                    Point3d ipt=Point3d.Origin;

                    if (ptres.Status != PromptStatus.Cancel)
                    {
                        ipt = ptres.Value;
                    }

                    using (IdMapping map = new IdMapping())
                    {
                        db.DeepCloneObjects(ids, bref.BlockId, map, false);

                        ObjectId clid = map[bref.ObjectId].Value;

                        BlockReference brefclone = (BlockReference)tr.GetObject(clid, OpenMode.ForWrite);

                        brefclone.Position =ipt;

                    }

                    tr.Commit();

                }
            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(ex.Message);
            }

        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333399" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 17:40:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417619#M56255</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-04-17T17:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417635#M56256</link>
      <description>&lt;P&gt;&lt;STRONG&gt;EDIT:&lt;/STRONG&gt; Wow, wow, wow, I was reading the first page and didn't see the second page&amp;nbsp;&lt;img id="smileylol" class="emoticon emoticon-smileylol" src="https://forums.autodesk.com/i/smilies/16x16_smiley-lol.png" alt="Smiley LOL" title="Smiley LOL" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That solved the second problem!&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How should I use chr(13)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PromptPointOptions pto = new PromptPointOptions(chr(13) + "Pick a block insertion point: ");&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;gives the same problem&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greets&lt;/P&gt;&lt;P&gt;Klaus&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 17:48:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417635#M56256</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-17T17:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417647#M56257</link>
      <description>&lt;P&gt;Well,&amp;nbsp;I am surprised the chr function is not automatically in c#, but anyway, Oleg's code reminded me of the appropriate way to send a newline in c# (and lisp)&amp;nbsp; use "\nPick a block insertion point: "&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 17:53:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417647#M56257</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2012-04-17T17:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417749#M56258</link>
      <description>&lt;P&gt;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt; That's great!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The block is pasted dreamlike.&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BUT: When I refresh my blocklist, I havn't got a new entry for the pasted block. That means, in my list is only the old entry.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;public void setBlockList()
{
   BlockList = new List&amp;lt;String&amp;gt;();
   using (tr = db.TransactionManager.StartTransaction())
   {
      BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
      foreach (ObjectId objId in bt)
      {

         BlockTableRecord btr = (BlockTableRecord)tr.GetObject(objId, OpenMode.ForRead);
         if (isAttDef(btr))
         {
            BlockList.Add(btr.Name);
         }
      }
   }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;That is my Blocklist-Function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you know why it fails?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greets&lt;/P&gt;&lt;P&gt;Klaus&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 18:16:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417749#M56258</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-17T18:16:08Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417863#M56259</link>
      <description>&lt;P&gt;I didn't see nothing wrong with your code&lt;/P&gt;&lt;P&gt;Perhaps you might be want to refresh BlockList first&lt;/P&gt;&lt;P&gt;Something like:&lt;/P&gt;&lt;PRE&gt;        public void setBlockList()
        {
          List&amp;lt;String&amp;gt;  BlockList = new List&amp;lt;String&amp;gt;();
          Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
          Database db = doc.Database;
          Editor ed = doc.Editor;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            { 
                BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                foreach (ObjectId objId in bt)
                {
                    BlockTableRecord btr = (BlockTableRecord)tr.GetObject(objId, OpenMode.ForRead);
                    if (btr.HasAttributeDefinitions)
                   // if (isAttDef(btr))
                    { 
                        BlockList.Add(btr.Name); 
                    } 
                }
            }
            foreach (string bname in BlockList)
            {
                ed.WriteMessage("\n{0}", bname);
            }

        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333399" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 18:55:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417863#M56259</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-04-17T18:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417909#M56260</link>
      <description>&lt;P&gt;I call my setBlockList()-Function direkt after the Commit. No Copy-Blockname.....&amp;nbsp;&lt;img id="smileyindifferent" class="emoticon emoticon-smileyindifferent" src="https://forums.autodesk.com/i/smilies/16x16_smiley-indifferent.png" alt="Smiley Indifferent" title="Smiley Indifferent" /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the commandline (&lt;/P&gt;&lt;PRE&gt;ed.WriteMessage("\n{0}", bname);&lt;/PRE&gt;&lt;P&gt;) is only one blockname too, the blockname of blk (using the function you posted).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Greets&lt;/P&gt;&lt;P&gt;Klaus&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 19:13:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3417909#M56260</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-04-17T19:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Block-Functions (Select, Explode, etc.)</title>
      <link>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3418249#M56261</link>
      <description>&lt;P&gt;I don't think it is failing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think you still don't quite understand the difference between a BlockReference and a BlockTableRecord.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are listing BlockTableRecords in your Block List.&amp;nbsp; When you copy/paste, you are creating a new BlockReference pointing to the same BlockTableRecord as the original copied BlockReference.&amp;nbsp; This does not create a new BlockTableRecord.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There can only be one BlockTableRecord with a given name, but there can (and usually will be) many BlockReferences that point to same BlockTableRecord.&amp;nbsp; That is really the point of Blocks, that you store the definition of the block (BlockTableRecord) once in the BlockTable, and then you create multiple instances of the block (BlockReference) as many times as needed in the Model or Paper spaces.&amp;nbsp; This saves space in the database and keeps the drawing size smaller, because the BlockReferences just contain a pointer to the BlockTableRecord, instead of containing all of the information for the lines, polylines and whatever other geometry they might contain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm still looking for the old post of mine that explains the difference in greater detail...&lt;/P&gt;</description>
      <pubDate>Tue, 17 Apr 2012 22:15:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/block-functions-select-explode-etc/m-p/3418249#M56261</guid>
      <dc:creator>chiefbraincloud</dc:creator>
      <dc:date>2012-04-17T22:15:31Z</dc:date>
    </item>
  </channel>
</rss>

