Add-In Keyboard Shortcut

Here is a short item from a case handled by Saikat Bhattacharya:

Question:
How can I define keyboard shortcuts for external commands in the Revit 2010 add-ins tab?

Answer:
Shortcut keys for Revit are defined by adding entries to the file KeyboardShortcuts.txt.
This file is located in the Revit Program folder, together with Revit.exe and Revit.ini.
It contains a commented header section describing how to construct a new shortcut key entry.

A shortcut definition consists of a line specifying the key sequence, an action type and the action string.
The key sequence is quoted, the action type is ‘ribbon’ for add-ins, and the action string is the hyphen-delimited path to the ribbon item to activate.
Example:

"WA"  ribbon:"Home-Basic Modeling Tools-Wall"

Since add-ins are located in the ribbon, the action item for an add-in will always be ‘ribbon’.
To specify the Add-Ins tab, you need to replace the hyphen by an underscore, because the hyphen is reserved as a separator character in the keyboard shortcut definition.
Therefore, the first item in the shortcut definition for an external command is ‘Add_Ins’.
The next items specify the panel name, which is ‘External’, followed by ‘External Tools’ for the external commands pulldown button.
So for a simple external command named XyzCommand in Revit.ini, the complete keyboard shortcut definition might be:

"XYZ" ribbon:"Add_Ins-External-External Tools-XyzCommand"

Comments

13 responses to “Add-In Keyboard Shortcut”

  1. Hey I have been looking at these samples and tech tips over the past few months prior to the Revit 2010 release. It seems like there is a major road block for those of us that are looking to create additional functionality to Revit. It would be really nice if someday you had an example of how to pick a point in Revit. Or am I the only person trying to do so :(

  2. Dear Greg,
    Thank you for your query, which I completely understand and support. I brought your comment as well as another one in a similar vein by Jim Massengale to the development team’s attention, so they are highly aware of this issue as well.
    Cheers, Jeremy.

  3. Would it be possible to create an API that would be able to save DOWN Revit files?

  4. Dear Darick,
    When you say ‘save down’, am I correct in assuming that you mean save a file back to a previous Revit file version? Nope, there is no such support in the API, and if there were, it would probably be made available in the product first.
    Cheers, Jeremy.

  5. Hi Jeremy,
    do you why I’ve got some functions wich are grayed out in ExternalTools menu?
    Cheers

  6. Dear Pierre,
    I looked at that issue in
    http://thebuildingcoder.typepad.com/blog/2009/06/rfa-version-grey-commands-family-context-and-rdb-link.html#2
    Several interesting comments have been added to that post as well.
    Cheers, Jeremy.

  7. I’ve noticed that when I unload an other dll, it works….strange not?

  8. Dear Pierre,
    I have not heard that one before … strange indeed.
    Cheers, Jeremy.

  9. Thx Jeremy,
    I’m gonna check.
    Cheers!

  10. Hi Jeremy!
    how about toggling underlay visibility to None? I know it can’t be possible to turn it on, since you have to choose the plan, but I guess it is possibile to do it for none.
    is there a line we can put in the txt file?
    like:
    “VU” ribbon:”View-Graphics-View Properties-Underlay-None” ?
    thanks in advance,
    Stefano

  11. Dear Stefano,
    If Revit has already defined a shortcut for this operation, it should definitely be possible to automate launching it somehow.
    However, I do not see the shortcut that you mention above in my KeyboardShortcuts.txt. The only one I see referring to underlay is this one, commented out:
    ; “” ribbon:”Manage-Project Settings-Settings-Halftone / Underlay”
    I have not used any tool such to send keystrokes to Revit in 2010, but it seems that others are happily doing so. Here are some posts based on 2009 on the subject:
    http://thebuildingcoder.typepad.com/blog/2009/01/autohotkey.html
    http://thebuildingcoder.typepad.com/blog/2009/02/selection-questions.html#1248007
    http://thebuildingcoder.typepad.com/blog/2009/05/vb-samples-and-other-questions.html#1
    Cheers, Jeremy.

  12. hi
    I have try out this one
    “XYZ” ribbon:”Add_Ins-External-External Tools-XyzCommand”
    but Shortcut didnt get triggered.
    i have class command class-FamilyOptions
    ; other alternates
    “TY” ribbon:”Add_Ins-External-External Tools-FamilyOptions”

  13. Russ Green Avatar
    Russ Green

    could you please update this for 2013? I’m sending keystrokes from my addin to run Revit commands like purge unused and I’d really like to be able to set the keyboard shortcut for a given Revit command at runtime.
    Thanks

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading