<?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: API queue command &amp;quot;CommandId&amp;quot; cannot be invoked in this context in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971722#M3517</link>
    <description>&lt;P&gt;You say, i&lt;SPAN&gt;f I post the command from a modeless window, there is no such problem.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That is unfortunate; there should be a problem!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 21 Aug 2024 08:29:04 GMT</pubDate>
    <dc:creator>jeremy_tammik</dc:creator>
    <dc:date>2024-08-21T08:29:04Z</dc:date>
    <item>
      <title>API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971672#M3515</link>
      <description>&lt;P&gt;I am trying to post a Revit command from a dockable panel. Some commands post without problems and some do not post at all. For example, the "Select by ID" command. The following message appears in the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Jrn.Directive _&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"IdleTimeTaskInvocation" , "2.PostCommandTask" , 0 _&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;, "{}" &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;' 0:&amp;lt; API_SUCCESS { API queue command ID_SELECT_BY_ID cannot be invoked in this context. } &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;'H 21-Aug-2024 10:25:19.159; 0:&amp;lt; &lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;Jrn.Directive _&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;"IdleTimeTaskInvocation" , "2.PostCommandTask" , 0 _&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;, "end"&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I initialize my plugin in the OnStartup method, I get an instance of UIApplication:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static UIApplication UiApplication { get; private set; }

public void OnStartup(UIControlledApplication application)
{
    _uiControlledApplication.Idling += UiControlledApplicationOnIdling;
}

private void UiControlledApplicationOnIdling(object sender, IdlingEventArgs e)
{
    if (sender is UIApplication application &amp;amp;&amp;amp; HasTabAndPanel())
    {
        UiApplication = application;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I post the command like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;App.UiApplication.PostCommand(commandId);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried posting the command through Dispatcher, which I also received in OnStartup:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;App.Dispatcher.Invoke(() =&amp;gt; App.UiApplication.PostCommand(commandId));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And through IExternalEventHandler, which I also created in the OnStartup method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;App.RevitEvent.Run(() =&amp;gt; App.UiApplication.PostCommand(commandId));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I post the command from a modless window, there is no such problem. Even IExternalEventHandler doesn't need to be used. So how to correctly post a command from a dockable panel?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 08:02:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971672#M3515</guid>
      <dc:creator>ModPlus</dc:creator>
      <dc:date>2024-08-21T08:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971713#M3516</link>
      <description>&lt;P&gt;You dockable panel lives in a modeless environment outside of a valid Revit API context.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, you cannot make any valid Revit API calls from it directly at all. Not PostCommand nor anything else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To achieve what you are asking for, you can implement a external event. In your modeless dockable panel code, you can raise the external event. Then, at some point in the future, Revit will call the&amp;nbsp;external event handler, its Execute method. The&amp;nbsp;Execute method provides a&amp;nbsp;valid Revit API context from which PostCommand and other Revit API methods can be called.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 08:25:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971713#M3516</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2024-08-21T08:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971722#M3517</link>
      <description>&lt;P&gt;You say, i&lt;SPAN&gt;f I post the command from a modeless window, there is no such problem.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That is unfortunate; there should be a problem!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 08:29:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971722#M3517</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2024-08-21T08:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971744#M3518</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;You dockable panel lives in a modeless environment outside of a valid Revit API context.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore, you cannot make any valid Revit API calls from it directly at all. Not PostCommand nor anything else.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To achieve what you are asking for, you can implement a external event. In your modeless dockable panel code, you can raise the external event. Then, at some point in the future, Revit will call the&amp;nbsp;external event handler, its Execute method. The&amp;nbsp;Execute method provides a&amp;nbsp;valid Revit API context from which PostCommand and other Revit API methods can be called.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;As I wrote in the post - I tried an external event. This does not solve the problem with posting commands&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 08:45:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971744#M3518</guid>
      <dc:creator>ModPlus</dc:creator>
      <dc:date>2024-08-21T08:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971786#M3519</link>
      <description>&lt;P&gt;You say, a&lt;SPAN&gt;s I wrote in the post - I tried an external event. This does not solve the problem with posting commands.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Sorry, I still do not see exactly how you are setting up the interaction with the external event, nor how it is being raised from the modeless context. I do see that you registered an Idling event handler. That is something else, not an external event. I do no know what your variables App refer to, or RevitEvent. I am getting confused about what you are doing, more and more.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The solution is very simple really, and quite clearly and cleanly demonstrated by the Revit SDK samples ModelessForm_ExternalEvent and ModelessForm_IdlingEvent.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 09:13:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971786#M3519</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2024-08-21T09:13:10Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971818#M3520</link>
      <description>&lt;P&gt;My implementation:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using ModPlusAPI.Windows;

[PublicAPI]
public class RevitEvent : IExternalEventHandler
{
    private Action _doAction;
    private readonly ExternalEvent _exEvent;

    public RevitEvent()
    {
        _exEvent = ExternalEvent.Create(this);
    }

    public bool IsActionExecuted { get; private set; }

    public void Run(Action doAction)
    {
        _doAction = doAction;
        _exEvent.Raise();
    }

    public void Execute(UIApplication app)
    {
        try
        {
            IsActionExecuted = true;
            _doAction?.Invoke();
            IsActionExecuted = false;
        }
        catch (Exception exception)
        {
            IsActionExecuted = false;
            exception.ShowInExceptionBox();
        }
    }

    public string GetName()
    {
        return "RevitEvent";
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Creating an instance with placement in a static property:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public class App : IExternalApplication
{
    private static UIControlledApplication _uiControlledApplication;

    public static RevitEvent RevitEvent { get; private set; }

    public static UIApplication UiApplication { get; private set; }

    public Result OnStartup(UIControlledApplication application)
    {
        _uiControlledApplication = application;
        _uiControlledApplication.Idling += UiControlledApplicationOnIdling;

        RevitEvent = new RevitEvent();
    }

    private void UiControlledApplicationOnIdling(object sender, IdlingEventArgs e)
    {
        if (sender is UIApplication application &amp;amp;&amp;amp; HasTabAndPanel())
        {
            UiApplication = application;
            _uiControlledApplication.Idling -= UiControlledApplicationOnIdling;
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using from dockable panel:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private void StartCommand(RevitCommandId commandId) =&amp;gt; App.RevitEvent.Run(() =&amp;gt;
{
    App.UiApplication.PostCommand(commandId);
});&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 21 Aug 2024 09:23:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971818#M3520</guid>
      <dc:creator>ModPlus</dc:creator>
      <dc:date>2024-08-21T09:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971834#M3521</link>
      <description>You should use IExternalEventHandler in the modeless to post the commands. If is working without IExternalEventHandler is by luck.&lt;BR /&gt;&lt;BR /&gt;Did you test to post the ID_SELECT_BY_ID inside a simple IExternalCommand?&lt;BR /&gt;</description>
      <pubDate>Wed, 21 Aug 2024 09:33:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971834#M3521</guid>
      <dc:creator>ricaun</dc:creator>
      <dc:date>2024-08-21T09:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971845#M3522</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4176855"&gt;@ricaun&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;You should use IExternalEventHandler in the modeless to post the commands. If is working without IExternalEventHandler is by luck.&lt;BR /&gt;&lt;BR /&gt;Did you test to post the ID_SELECT_BY_ID inside a simple IExternalCommand?&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I have already written about this several times above - I tried IExternalEventHandler. The command fails to run only if it is posted from the panel. In all other variants (from a window or from a IExternalCommand) the command runs without any problems&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 09:39:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971845#M3522</guid>
      <dc:creator>ModPlus</dc:creator>
      <dc:date>2024-08-21T09:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971853#M3523</link>
      <description>&lt;P&gt;Your code is very confusing for me. Why are you subscribing to the Idling event? Can you remove that, please to clarify how the interaction with the external event is set up? The Idling event is a completely different animal from the external event, and you make it very confusing for yourself and others if you try to use both at the same time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 09:46:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971853#M3523</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2024-08-21T09:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971971#M3524</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14668997"&gt;@ModPlus&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I have already written about this several times above - I tried IExternalEventHandler. The command fails to run only if it is posted from the panel. In all other variants (from a window or from a IExternalCommand) the command runs without any problems&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Your code looks right. Maybe &lt;STRONG&gt;IExternalEventHandler&lt;/STRONG&gt; does not work with &lt;STRONG&gt;ID_SELECT_BY_ID&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this one? &lt;STRONG&gt;PostableCommand.&lt;SPAN class=""&gt;SelectById &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt;that your are using?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: your could use some extension to 'convert' &lt;STRONG&gt;UIControlledApplication&lt;/STRONG&gt; to &lt;STRONG&gt;UIApplication&lt;/STRONG&gt; instead of using the &lt;STRONG&gt;Idling&lt;/STRONG&gt; approach. Like: &lt;A href="https://github.com/ricaun-io/ricaun.Revit.DI/blob/master/ricaun.Revit.DI/Extensions/UIControlledApplicationExtension.cs" target="_blank" rel="noopener"&gt;https://github.com/ricaun-io/ricaun.Revit.DI/blob/master/ricaun.Revit.DI/Extensions/UIControlledApplicationExtension.cs&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 10:48:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12971971#M3524</guid>
      <dc:creator>ricaun</dc:creator>
      <dc:date>2024-08-21T10:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12972034#M3525</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/824630"&gt;@jeremy_tammik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here the test project (Revit 2024) and video. You can try it by yourself&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6360754790112w960h540r612" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6360754790112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6360754790112w960h540r612');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6360754790112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 11:17:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12972034#M3525</guid>
      <dc:creator>ModPlus</dc:creator>
      <dc:date>2024-08-21T11:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12972063#M3526</link>
      <description>&lt;P&gt;That's how that command works, you need to have a view selected or something.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you click in an dockable panel, could be the default &lt;STRONG&gt;Project Browser&lt;/STRONG&gt; the command &lt;STRONG&gt;Select by ID&lt;/STRONG&gt; goes to disable.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ricaun_1-1724239995662.png" style="width: 300px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1400295i1EA64AA6BB3A0DED/image-size/small?v=v2&amp;amp;px=200" role="button" title="ricaun_1-1724239995662.png" alt="ricaun_1-1724239995662.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And if you click in the current view, the command is enabled.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ricaun_0-1724239983637.png" style="width: 300px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1400294i3ACC0039E2F53792/image-size/small?v=v2&amp;amp;px=200" role="button" title="ricaun_0-1724239983637.png" alt="ricaun_0-1724239983637.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is video, and I tested with the &lt;STRONG&gt;IExternalCommand&lt;/STRONG&gt; and does not work when the command &lt;STRONG&gt;Select by ID&lt;/STRONG&gt; is disable. That's how post command works. &lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;div class="video-embed-center video-embed"&gt;&lt;iframe class="embedly-embed" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F6RMTAZTFRzQ%3Ffeature%3Doembed&amp;amp;display_name=YouTube&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D6RMTAZTFRzQ&amp;amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F6RMTAZTFRzQ%2Fhqdefault.jpg&amp;amp;type=text%2Fhtml&amp;amp;schema=youtube" width="200" height="112" scrolling="no" title="Revit API Forum - PostableCommand.SelectById" frameborder="0" allow="autoplay; fullscreen; encrypted-media; picture-in-picture" allowfullscreen="true"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 11:39:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12972063#M3526</guid>
      <dc:creator>ricaun</dc:creator>
      <dc:date>2024-08-21T11:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12972068#M3527</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4176855"&gt;@ricaun&lt;/a&gt;&amp;nbsp;great observation! It all makes sense now. I just have to figure out a solution. I'll try to activate the view...&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 11:45:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12972068#M3527</guid>
      <dc:creator>ModPlus</dc:creator>
      <dc:date>2024-08-21T11:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12972337#M3528</link>
      <description>&lt;P&gt;Unfortunately, re-activating the view before posting the command did not work. I even tried moving the focus to the document control, but that didn't work either. Does anyone have any other ideas?&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 13:40:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12972337#M3528</guid>
      <dc:creator>ModPlus</dc:creator>
      <dc:date>2024-08-21T13:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12972672#M3529</link>
      <description>&lt;P&gt;Hi ModPlus,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that the view has no focus, it seems that PostableCommand.SelectById needs to be enabled for it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did this little test just to confirm that focus is needed on the view, with this it works:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="test.gif" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1400441i9F88E2E53AF64434/image-size/medium?v=v2&amp;amp;px=400" role="button" title="test.gif" alt="test.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private DispatcherTimer m_Timer;
public ICommand PostSelectByIdCommand =&amp;gt; new RelayCommand(() =&amp;gt;
{
    m_Timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(100) };
    m_Timer.Tick += Timer_Tick;
    m_Timer.Start();

    try
    {
        App.UiApplication.ActiveUIDocument.Selection.PickPoint(Autodesk.Revit.UI.Selection.ObjectSnapTypes.None);
    }
    catch { }
    finally
    {
        m_Timer.Stop();
        m_Timer.Tick -= Timer_Tick;
    }

    App.RevitEvent.Run(() =&amp;gt; SafeExecute(() =&amp;gt; 
    {
        App.UiApplication.PostCommand(RevitCommandId.LookupPostableCommandId(PostableCommand.SelectById));
    }));
});
private void Timer_Tick(object sender, EventArgs e)
{
    PressService.PostMessage(ComponentManager.ApplicationWindow, (uint)PressService.KEYBOARD_MSG.WM_KEYDOWN, (uint)Keys.Escape, 0);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 15:46:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12972672#M3529</guid>
      <dc:creator>Speed_CAD</dc:creator>
      <dc:date>2024-08-21T15:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12983045#M3530</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/45203"&gt;@Speed_CAD&lt;/a&gt;&amp;nbsp; interesting solution! Thank you! I'll try to use it&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 05:58:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12983045#M3530</guid>
      <dc:creator>ModPlus</dc:creator>
      <dc:date>2024-08-27T05:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: API queue command "CommandId" cannot be invoked in this context</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12983558#M3531</link>
      <description>&lt;P&gt;Thank you for the interesting discussion, research and documentation. I shared a short pointer on the blog:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2024/08/api-context-background-process-postcommand.html#5" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2024/08/api-context-background-process-postcommand.html#5&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2024 11:23:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/api-queue-command-quot-commandid-quot-cannot-be-invoked-in-this/m-p/12983558#M3531</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2024-08-27T11:23:53Z</dc:date>
    </item>
  </channel>
</rss>

