How excecute shortcut from api revit

How excecute shortcut from api revit

Anonymous
Not applicable
727 Views
3 Replies
Message 1 of 4

How excecute shortcut from api revit

Anonymous
Not applicable

hi everyone

i developing a revit addin ussing C# 2012. Need excecute my shortcut (WS) when i press a button on my form. This shortcut open the WorkSets box. a friend recommended me use the method UiApplication.PostCommand, i try with this code:

 

 

UIApplication uiapp = _commandData.Application;

uiapp.PostCommand(Shortcut="WS");

 

uiapp.PostCommand(Shortcut("WS"));

 

uiapp.PostCommand(commandId("WS"));

 

uiapp.PostCommand("WS");

 

but no one to work, can somebody help me.

 

Regards.

0 Likes
728 Views
3 Replies
Replies (3)
Message 2 of 4

arnostlobel
Alumni
Alumni
marcosmateo:

I do not know what exactly your are developing, but based on what you've stated so far my guess is that PostCommand is not a feature you want or need. Basically, when you post a Revit command to be executed you are not expected to continue executing your application, whatever that is (typically an external command). A PostCommand is sort of assumed to be the last thing you do in your add-in just before you return the control back to Revit (e.g. you return Success from your ExternalCommand.Execute method). The posted command is then supposed to follow up your external command in somewhat seamless fashion (from the perspective of the end-user).

Arno?t L?bel
Autodesk, Revit R&D
Arnošt Löbel
0 Likes
Message 3 of 4

Anonymous
Not applicable

Arnošt
I don't if  the postcommand method is correct. My direct question would be: you can execute a shortcut when I press a button on my form ?. exist a example?

 

Marcos

0 Likes
Message 4 of 4

arnostlobel
Alumni
Alumni

The answer to your direct question is: No, you cannot execute a Revit shortcut from a form of your external command; at least not in a way we can  support and endorse. Naturally, the application is yours and you can use whatever you feel like you must, including the windows messaging system. However, we cannot guarantee such workarounds would work dependably, thus I cannot recommend it as a solution for a commercial application. 

Arnošt Löbel