How to disable and enable the customized shortcuts in Revit 2014

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have to disable and enable the customized shortcuts assigned to the specified command .
e.g Let's say I have a document A and B opened in the revit.When A document is active,I want that customized shortcut for the paste command should be enabled and when I switch to the document B ,customized shortcut for the paste command should be disabled.
Again when I switch to the document A,customized shortcut for the paste command should be enabled.
void UpdateShortcuts()
{
Dictionary<string, ShortcutItem> allCommands = ShortcutsHelper.Commands;
var map = ShortcutsHelper.LoadShortcuts();
Dictionary<string, ShortcutItem> updateShortcust = new Dictionary<string, ShortcutItem>();
foreach (string cmdId in CmdIdsForRibbonMenuItems)
{
if (!string.IsNullOrEmpty(cmdId)
&& .DisabledRibbonItemCmdIds.Contains(cmdId))
{
if (map.ContainsKey(cmdId))
{
map[cmdId].Shortcuts.Clear();
var shortCutItem = map[cmdId];
updateShortcust.Add(cmdId, shortCutItem);
}
}
//test
if (!string.IsNullOrEmpty(cmdId)
&& mRevitContext.ApplicationSettings.EnabledRibbonItemCmdIds.Contains(cmdId))
{
if (map.ContainsKey(cmdId))
{
var shortCutItem = map[cmdId];
updateShortcust.Add(cmdId, shortCutItem);
}
}
}
UIFrameworkServices.KeyboardShortcutService.applyShortcutChanges(updateShortcust);
}
With this approach,it disables the customized shortcut but when we enable it as above I add a shortcut from the map and again applyshortcutchanges,it does not enable it.
Your help will be much appreciated.
Thanks,
ACAD_VINOD