<?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: Exploding AEC objects after setting implied selection is behaving inconsistently in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/exploding-aec-objects-after-setting-implied-selection-is/m-p/13248450#M1236</link>
    <description>&lt;P&gt;Of course that worked. As always thank you very much. Is there any documentation regarding Editor.InitCommandVersion()? I like to learn more about these obscure "tools" so I might be ready next time.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Jan 2025 22:29:40 GMT</pubDate>
    <dc:creator>nshupeFMPE3</dc:creator>
    <dc:date>2025-01-07T22:29:40Z</dc:date>
    <item>
      <title>Exploding AEC objects after setting implied selection is behaving inconsistently</title>
      <link>https://forums.autodesk.com/t5/net-forum/exploding-aec-objects-after-setting-implied-selection-is/m-p/13247999#M1234</link>
      <description>&lt;P&gt;I was trying to add exploding AEC objects as a step in a larger command.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;So in my command class I simply have this&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;[CommandMethod(nameof(CleanupTest))]
public void CleanupTest()
{
    Cleanup.CleanupTool.Cleanup();
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Then in the Cleanup method&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static class CleanupTool
{
    private static Database _db = null;
    private static Editor _ed = null;
    private static List&amp;lt;ObjectId&amp;gt; _allEntities = new List&amp;lt;ObjectId&amp;gt;();

    public static void Cleanup()
    {
        Document doc = Application.DocumentManager.MdiActiveDocument;
        _db = doc.Database;
        _ed = doc.Editor;
        _allEntities.Clear();

        _db.UnlockTurnOnThawAllLayers();
        
        GetAllEntities(_ed);
        if (!_allEntities.Any()) return;

        ExplodeAEC();

        

        bool moreBlocks = true;

        while (moreBlocks)
        {
            moreBlocks = ExplodeBlocks();
        }
      ///the rest of my code

   }
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;I get a selection so I know what entities the user wants to operate with, and then I try to explode the AEC objects which requires sending the EXPLODE command instead of exploding using the API&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static void GetAllEntities(Editor ed)
{
    var totalSelection = ed.GetSelection(new PromptSelectionOptions
    {
        MessageForAdding = $"\nSelect the FLOOR plan to clean:"
    });
    if (totalSelection.Status != PromptStatus.OK) return;

    _allEntities = totalSelection.Value.GetObjectIds().ToList();
}

private static void ExplodeAEC()
{
    var aec = _allEntities
        .Where(id =&amp;gt; id.ObjectClass.DxfName.Contains("AEC"))
        .ToList();

    if (!aec.Any()) return;

    _ed.SetImpliedSelection(aec.ToArray());

    //_ed.Document.SendStringToExecute("._EXPLODE", true, false, false);
    _ed.Command("._EXPLODE", "P");
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Neither using Editor.Command() or Document.SendStringToExecute() work in this context. The terminal says this&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Select the FLOOR plan to clean:
._EXPLODE
Select object: P
*Invalid selection*
Expects a point or Last/ALL/Group&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;But If I instead extract the AEC portion into its own command then it works&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;[CommandMethod(nameof(CleanAEC))]
public void CleanAEC()
{
    var _ed = Active.Editor;

    var selection = _ed.GetSelection();

    if (selection.Status != PromptStatus.OK) return;

    var aec = selection.Value.GetObjectIds()
        .Where(id =&amp;gt; id.ObjectClass.DxfName.Contains("AEC"))
        .ToList();

    if (!aec.Any()) return;

    _ed.SetImpliedSelection(aec.ToArray());

    _ed.Document.SendStringToExecute("._EXPLODE P", true, false, false);
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;I have tried commenting out the rest of the Cleanup method code to see if something that happens after ExploeAEC is causing the problem. Unfortunately it did not seem to help.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2025 17:58:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/exploding-aec-objects-after-setting-implied-selection-is/m-p/13247999#M1234</guid>
      <dc:creator>nshupeFMPE3</dc:creator>
      <dc:date>2025-01-07T17:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Exploding AEC objects after setting implied selection is behaving inconsistently</title>
      <link>https://forums.autodesk.com/t5/net-forum/exploding-aec-objects-after-setting-implied-selection-is/m-p/13248389#M1235</link>
      <description>&lt;P&gt;Try it like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private static void ExplodeAEC()
{
   var aec = _allEntities
         .Where(id =&amp;gt; id.ObjectClass.DxfName.Contains("AEC"))
         .ToArray();

   if(!aec.Any()) return;

   var ss = SelectionSet.FromObjectIds(aec);
   ed.InitCommandVersion(2);
   ed.Command("._EXPLODE", ss, "");
}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 07 Jan 2025 21:38:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/exploding-aec-objects-after-setting-implied-selection-is/m-p/13248389#M1235</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-01-07T21:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Exploding AEC objects after setting implied selection is behaving inconsistently</title>
      <link>https://forums.autodesk.com/t5/net-forum/exploding-aec-objects-after-setting-implied-selection-is/m-p/13248450#M1236</link>
      <description>&lt;P&gt;Of course that worked. As always thank you very much. Is there any documentation regarding Editor.InitCommandVersion()? I like to learn more about these obscure "tools" so I might be ready next time.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Jan 2025 22:29:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/exploding-aec-objects-after-setting-implied-selection-is/m-p/13248450#M1236</guid>
      <dc:creator>nshupeFMPE3</dc:creator>
      <dc:date>2025-01-07T22:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: Exploding AEC objects after setting implied selection is behaving inconsistently</title>
      <link>https://forums.autodesk.com/t5/net-forum/exploding-aec-objects-after-setting-implied-selection-is/m-p/13250780#M1237</link>
      <description>&lt;P&gt;InitCommandVersion() tells the next command to be issued to use the same prompting sequence in scripted commands that it uses when the command is used interactively by the user.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A command will always use the legacy prompting sequence (if there is one) when it is being scripted, to avoid breaking script compatibility. InitCommandVersion() allows you to override that, to have a command use the same prompting sequence in scripted input that's used when the command is used interactively.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The EXPLODE command originally accepted only a single entity. At some point, it was changed to allow multiple objects to be selected, which involves a different prompting sequence. So in this case, InitCommandVersion() is telling EXPLODE to allow multiple objects to be supplied when it is being scripted, which it would otherwise not do.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 22:19:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/exploding-aec-objects-after-setting-implied-selection-is/m-p/13250780#M1237</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2025-01-08T22:19:20Z</dc:date>
    </item>
  </channel>
</rss>

