Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get Short key collection

16 REPLIES 16
Reply
Message 1 of 17
Anonymous
2035 Views, 16 Replies

How to get Short key collection

Hello ,

 

 

Please suggest how can i get list of revit short keys programatically.

 

 

Regrads,

Bhavana Gahlot

16 REPLIES 16
Message 2 of 17
jeremytammik
in reply to: Anonymous

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



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 17
jeremytammik
in reply to: jeremytammik

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

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 17
Revitalizer
in reply to: Anonymous

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




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 17
jeremytammik
in reply to: 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



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 6 of 17
Revitalizer
in reply to: jeremytammik

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

 




Rudolf Honke
Software Developer
Mensch und Maschine





Message 7 of 17
Anonymous
in reply to: Revitalizer

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

 

Message 8 of 17
Revitalizer
in reply to: Anonymous

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

 




Rudolf Honke
Software Developer
Mensch und Maschine





Message 9 of 17
Anonymous
in reply to: 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

 

 

 

Message 10 of 17
Revitalizer
in reply to: Anonymous

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.




Rudolf Honke
Software Developer
Mensch und Maschine





Message 11 of 17
jeremytammik
in reply to: Revitalizer

Dear Revitalizer,

 

Thank you for a very good answer.

 

I summarised this discussion here:

 

http://thebuildingcoder.typepad.com/blog/2015/02/keyboard-shortcuts-and-other-news.html

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 12 of 17
Anonymous
in reply to: Revitalizer

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

Message 13 of 17
Revitalizer
in reply to: jeremytammik

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




Rudolf Honke
Software Developer
Mensch und Maschine





Message 14 of 17
jeremytammik
in reply to: Revitalizer

Mille grazie, Rudi!

 

You too!

 

I have a week's holiday coming up as well    🙂

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 15 of 17
michellem
in reply to: jeremytammik

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

 

 

 

 

Message 16 of 17
jeremy_tammik
in reply to: michellem

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.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
Message 17 of 17
michellem
in reply to: jeremy_tammik

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report