Message 1 of 7
PostCommand of external command (coming from ribbon) not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I tried to execute an external command coming from an addin with ribbon. It's not working when I used the same code used for external command coming from addin without ribbon:
var commandName = "CustomCtrl_%CustomCtrl_%CustomCtrl_%Add-Ins%Revit Lookup%RevitLookupButton%RevitLookup.Commands.DashboardCommand"; // :RevitLookup.Commands.DashboardCommand
var commandId = RevitCommandId.LookupCommandId(commandName);
if(commandId != null && application.CanPostCommand(commandId)) {
application.PostCommand(commandId);
}
By consulting the journal, I found the correct string defining the external command :
Jrn.RibbonEvent "Execute external command:CustomCtrl_%CustomCtrl_%MyAddin%Commmands%test:MyAddmin.Commands.Test"
So the code is:
var commandName = "CustomCtrl_%CustomCtrl_%MyAddin%Commands%test"; // :MyAddmin.Commands.Test
var commandId = RevitCommandId.LookupCommandId(commandName);
if(commandId != null && application.CanPostCommand(commandId)) {
application.PostCommand(commandId);
}
The command is not executed and I found the following line in the journal:
'C 22-Jan-2025 14:39:12.602; DBG_INFO: CustomCtrl_%CustomCtrl_%MyAddin%Commands%testdoes not exist.: line 889 of E:\Ship24.3.1\2024_px64\Source\API\RevitAPIUI\Objects\APIUIApplicationHandwritten.cpp.
I don't undestand why API can find the commandId and returns true to CanPostCommand but the call to PostCommand raises an internal error. I tried to change the Transaction and Regeneration attributes over command class, but it has no effect.
Has anyone ever managed to do this?
All suggestions are welcome
Jonathan
--
Jonathan
Jonathan