Some people have asked about automating the creation of hotkeys as it can be abit fiddly for them to do it manually.
The problem is, like scripting most things, you really need to understand what is actually going on and why.
For example, to automate the creating a hotkey to print what is currently selected.
The script is simply "print (`ls -sl`);"
First of all we need to create a runTimeCommand, which ties the entire script needed to execute under a single runTimeCommand, just like most of maya's own scripts do.
runTimeCommand
-annotation "Prints whatever is currently selected"
-category "User"
-commandLanguage "mel"
-command ("print (`ls -sl`);")
printSelection;
This sets up everything we need to display the command in the hotkeyEditor, without it, you can still assign a command to a hotkey but when your try to find it in the hotkey editor, maya will have no knowledge of it.
Now we need to create a nameCommand which ties the a script to execute under a single string command, just like most of maya's own scripts do.
nameCommand
-annotation "printSelectionNameCommand"
-sourceType "mel"
-command ("printSelection")
printSelectionNameCommand;
Finally we assign a key which runs this command with
hotkey -keyShortcut "~" -name ("printSelectionNameCommand");
Now that does seem like alot of work, but it sets up everything you need and with abit of wotk, most of it could be automated, but the things you would need to check and the info you need to enter, theres pretty much no point creating an alternative version of the hotkeyEditor as it requires the same information.
What you could do, however, is to create perhaps hotkey presets, so instead of having to take 3 scripts as you move to a different station (3 being the pref's scripts "userHotkeys.mel", "userNamedCommands.mel" and "userRunTimeCommands.mel"), you could have them those hotkeys into a single custom script which saves its setup as a preset in its own script file.
This could be furthered by doing the same with shelves, window prefs etc, all executed from one script rather than having to transfer the entire prefs folder. Its fairly simple, definitely not the best way of going about it, but its certainly possible.
Sunday, 27 November 2011
Automating Hotkeys
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment