Wednesday, November 18, 2009

Revit Subscription Advantage Pack – Pushing the new keyboard shortcuts out to your office

The new Subscription Advantage Pack for Revit brings a new Keyboard Shortcuts dialog inside of Revit, for easier, on the fly editing of keyboard shortcuts.

The keyboardshortcuts.txt file is gone now from the Revit directory, the data is now stored in an XML format.

Our office has an installation tool for our API add ons, and part of this tool used to copy a keyboardshortcuts.txt file from a central location, onto the users Revit installation. This is obviously no longer useful, so how do we make sure our office are using standard keyboard shortcuts?

The answer is, there is now a KeyboardShortcuts.xml file stored in C:\Users\USERNAME\AppData\Local\Autodesk\Revit\Autodesk Revit Structure 2010\

of course this is different depending on the revit version you have, but our office uses revit structure exclusively so that wasn’t an issue for me. I believe this may point do the documents and settings folder for XP instead of C:\Users\ which is the Vista/Win7 replacement.

To get this location in C# I used:

   1:                  String currentKeyboard = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
   2:                  currentKeyboard += @"\Autodesk\Revit\Autodesk Revit Structure " + _revitYear + @"\KeyboardShortcuts.xml";

On line 1, I got the location to the C:\Users\USERNAME\AppData\Local\ folder

then on the second line I added the Revit specific path, _revitYear is a variable that I have populated from a config file to allow easy updating when our office upgrades each year.

You could improve on this code by checking for other Revit versions, or perhaps using the registry to gather which version was installed, but for our office this simple implementation worked fine – hopefully it gives you a base to start from!