[Maya 2022] Overriding hotkeys

Hello,

Context

In our studio, the artists must use our custom tools for saving and openning scenes. They start Maya from our launcher, which takes care of setting up Maya properly (plugins requirements for the project, custom shelves, custom menus, preferences, and custom hotkeys).

Answer

In order to override some hotkeys like ctrl+s, ctrl+o, (…), I added from the hotkey editor some user named commands executing python calls to our internal saver/opener, and assigned them to their respective hotkey.

Then, I add 2022/prefs/userNamedCommands.mel, 2022/prefs/userRunTimeCommands.mel and 2022/prefs/hotkeys/userHotkeys_Maya_Default_Duplicate.mel to our pipeline config files repository, and configured our launcher to copy these files to 2022/prefs/... at every Maya start.

Problem

The userNamedCommands and userRunTimeCommands are indeed registered and working, but the hotkey file seems to be ignored.

And if I was to manualy change the hotkeys from the Hotkey Editor after starting Maya that way, it would save a userHotkeys_Maya_Default_Duplicate1.mel (1 appended to the filename)

Questions

  • Any explanation for this behaviour?
  • Do I also have to unassigned the hotkeys from their previous bind (like the default SaveScene command? Because that is the only thing that doesn’t seem to be covered by these three .mel files I’m using.
  • Any workaround suggested?
  • Is there a pythonic way to achieve that?
  • Secondary question, but ideally, I’d prefer to keep all the pipeline-induced modifications in a container place. So does the files userNamedCommands.mel, userRunTimeCommands.mel and userHotkeys_Maya_Default_Duplicate.mel have to be named like that and place in 2022/prefs/ and 2022/prefs/hotkeys/ in order to be read, or could they be named differently and saved elsewhere?

Thank you, hope this is clear :slight_smile:

Also, I’m not fluent at Maya (coming from 3dsMax, Modo and Blender), so tell me if I’m trying to enforce habits that don’t really match Maya’s approach.

You can use python and have the script run at startup to assign hotkeys. Checkout the hotkeySet, and hotkey commands.

Here is a full example of how to assign a hotkey with python.

1 Like

Thank you very much, it works perfectly!