The user interface provides a command to export your shortcut keys to XML:
http://help.autodesk.com/view/RVT/2015/ENU/?guid=GUID-0A6F242A-EBEF-4B9B-B974-23006DC2E882
This command may possibly be launched programmatically as well using PostCommand:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.3
Please try it out and let us know what you find out.
Thank you!
Cheers,
Jeremy
Might be tricky to drive programmatically:
Either use PostCommand or Windows UI Automation to do the following:
View > Windows > User Interface > Keyboard Shortcuts > Export... > filename input > Save > Cancel.
If you use PostCommand, you will have to handle all the dialogues that pop up via the Revit API:
http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.32
Cheers,
Jeremy
Dear SoftwareTesting,
just read this file:
C:\Users\<YOUR_USER_NAME>\AppData\Roaming\Autodesk\Revit\Autodesk Revit 2015\KeyboardShortcuts.xml
As you can see, this is a per-user-file, so there may be several of them on your system.
Best regards,
Revitalizer
Dear Revitalizer,
Thank you for jumping in!
Is this file always generated automatically, or do you have to launch some Revit command to export it?
Does Revit keep it up to date automatically every time you make a change to the keyboard shortcots?
Thank you!
Cheers,
Jeremy
Hi Jeremy,
yes, Revit updates this file just if I changed the shortcuts in the GUI.
I don't know if there exists such a file if the user didn't change them yet, but I suppose so since there are not only user defined but also predefined shortcuts, e.g. WF for wireframe display mode.
Best regards,
Rudi
Thanks for your reply.
I tried C:\Users\<OUR_USER_NAME\AppData\Roaming\Autodesk\Revit\Autodesk Revit 2015\KeyboardShortcuts.xml path.
But xml file is not there. Could you plesae suggest me what i am doing wrong.
Thanks,
Bhavana
Dear SoftwareTesting,
are you sure that you use Revit 2015 ?
Are you sure this folder is visible ?
If you use the GUI and make a change to the existing shortcuts, e.g. by adding one: can you find this file after that ?
Since shortcuts are per user, this information needs to be stored, anyway.
Best regards,
Revitalizer
Thanks for reply.
After assigning one short key i am getting XML.
But i need this file without creting any short key from GUI.
Please advice.
Thanks,
Bhavana
Dear SoftwareTesting,
if the user hasn't changed his shortcuts, you can assume that he is using default settings.
Once you have such an XML file, you can extract this default information from this one file.
Just use your just newly created file as a template, minus your change.
Best regards,
Revitalizer.
Dear Revitalizer,
Thank you for a very good answer.
I summarised this discussion here:
http://thebuildingcoder.typepad.com/blog/2015/02/k
Cheers,
Jeremy
Thanks for your reply ,
If user does not change his settings in this case i need default settings in my program using Revit API.
Please suggest.
Regards,
Bhavana
Hi Jeremy,
an addition to your blog posting:
Since the KeyboardShortcuts.xml is localized (CommandName and Paths attributes), one will need to create one template per language.
CommandId and Shortcuts attributes are language independent, and in my German XML file, there is a default MD for "modify", "ändern" in German.
If you just want the CommandId-Shortcuts relation you need just one file version since this relation is language-independent.
Cheers, have a nice weekend,
Rudi
Mille grazie, Rudi!
You too!
I have a week's holiday coming up as well 🙂
Cheers,
Jeremy
Hello Everyone;
I just keep coming years late to the party. I was searching around about assigning keyboard shortcuts to custom commands and I found this post from 2015. Has there been any change in the Revit API since 2015 in this area?
If not, am I correct that thru the user interface, you can only add shortcuts to commands that appear on a ribbon tab? For example, it might be nice to have a keyboard shortcut to a macro or a dynamo script.
Michelle
You could simply execute your macro or Dynamo script manually and then check what entries that generates in the journal file. Most commands listed in the journal file, if not all, can be driven by the PostCommand API, and possibly (probably?) by a keyboard shortcut as well.
That's an interesting idea. I will have to give it a try - it is also a good reason to learn a bit more about the journal file.
Thanks much.