- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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:
Jrn.Directive _
"IdleTimeTaskInvocation" , "2.PostCommandTask" , 0 _
, "{}"
' 0:< API_SUCCESS { API queue command ID_SELECT_BY_ID cannot be invoked in this context. }
'H 21-Aug-2024 10:25:19.159; 0:<
Jrn.Directive _
"IdleTimeTaskInvocation" , "2.PostCommandTask" , 0 _
, "end"
When I initialize my plugin in the OnStartup method, I get an instance of UIApplication:
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 && HasTabAndPanel())
{
UiApplication = application;
I post the command like this:
App.UiApplication.PostCommand(commandId);
I tried posting the command through Dispatcher, which I also received in OnStartup:
App.Dispatcher.Invoke(() => App.UiApplication.PostCommand(commandId));
And through IExternalEventHandler, which I also created in the OnStartup method:
App.RevitEvent.Run(() => App.UiApplication.PostCommand(commandId));
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?
Solved! Go to Solution.
Developer Advocacy and Support +