How do I create custom hotkeys in RV?
Hi there!
Thank you for reaching out via community
Unfortunately itās not the most artist-friendly workflow
You can do it in three ways:
- Add an
.rvrc.mu
or.rvrc.py
file in your home directory. (more on this below) - Redefine key bindings in a custom Python package. This is very flexible and you can bundle key definitions with multiple RV versions at the same time.
- Change
rvui.mu
. This is a file that is included in every version of RV that defines the menus and their key bindings. This is easier but itās also very fragile. Youāll have to redefine hotkeys every time that you update your version of RV and have to remember that you havervui.mu
modified.
Package building can get complicated, so if you want a quick solution you can try this. If users want to add their own keybindings, they can be added to the userās .rvrc.mu
or .rvrc.py
files in their home directories.
Check out this section on the user manual RV User Manual - User Interface Key and Mouse Bindings.
If you check the default implementation of rvrc.mu
(You can find it under $RV_HOME/Mu/rvrc.mu
), it looks like this:
require rvui;
documentation:
"Called when a session is first created";
\: initialize (object;)
{
//
// To override default bindings just set them after you call this,
// otherwise, you need to provide all of the bindings if you
// replace it.
//
rvui.defineDefaultBindings();
//
// You can add to rvui.mainMenu before calling this
//
defineModeMenu("default", rvui.buildMainMenu());
//
// Make a new State object. Any object can be returned here
// (tuple, etc). In this case we're going to provide the default
// State object.
//
return rvui.newStateObject();
}
I wonāt paste the rvui.mu file as it is too big, but if you look at the defineDefaultBindings method, youāll find a bunch of bindings that look like this:
bind("key-down--.", incN(1), "Set Frame Increment to 1 (forward)");
bind("key-down--1", pixelRelativeScale(1.0), "Scale 1:1");
bind("key-down--2", pixelRelativeScale(2.0), "Scale 2:1");
bind("key-down--3", pixelRelativeScale(3.0), "Scale 3:1");
bind("key-down--4", pixelRelativeScale(4.0), "Scale 4:1");
bind("key-down--5", pixelRelativeScale(5.0), "Scale 5:1");
bind("key-down--6", pixelRelativeScale(6.0), "Scale 6:1");
bind("key-down--7", pixelRelativeScale(7.0), "Scale 7:1");
bind("key-down--8", pixelRelativeScale(8.0), "Scale 8:1");
bind("key-down--A", toggleRealtime, "Toggle Real-Time Playback");
bind("key-down--C", toggleCacheModeFunc(CacheGreedy), "Toggle Region Caching");
bind("key-down--D", toggleDisplayLUT, "Toggle Display LUT");
bind("key-down--F", enterFPS, "Enter FPS Value From Keyboard");
You donāt need to know what it does, all you really need to change the numbers/letters to the key-down--
bindings. This way each user can define key bindings in their copy of the rvrc.mu
file after copying it to their home directory as ~/.rvrc.mu
.
I have attached a python example as well! bind_example_rvrc.py (305 Bytes)
If you decide to go a package way, I can show you how to do that as well.
Thanks,
Alexa
whatās the easiest way to disable a default hotkey like āqā?
I created a ~/rvrc.py file and added the below lines but it has no effect:
from rv import rvui, commands, extra_commands
def initialize():
rvui.defineDefaultBindings()
return rvui.newStateObject()
def setup():
def disable_Q(event):
pass
commands.bind("default", "global", "q", disable_Q, "Null")
return
DOH, got it. had to be
commands.bind("default", "global", "key-down--q", disable_Q, "Null")
@frank Hereās a package version of the same thing in case you want it a bit easier to bundle up.
Q_Disable-1.0.rvpkg (758 Bytes)
Ah nice, thanks Michael!
The answer is easy, Kessler probably has a package for that
thanks for the documentation on this. Iām very new to configuring RV but wanted to set up a few defaults and hotkeys.
How would I go about finding out what the command is for setting hotkeys for items not listed in the example. For instance I am comfortable looking for a line such as this
bind(ākey-downā5ā, pixelRelativeScale(5.0), āScale 5:1ā);
and replacing the sections where needed. In nuke for instance I can easily mouse over to find what a knob is to set but donāt know how to do that in RV
In my case I would like to set a hotkey for switching to ādefault stackā and another set of hotkeys to switch between frames and movie files.
Hi @keggers,
Almost everything state-changing is represented in the rv session file with exception of display settings. One method I use readily is to save an RV session prior to changing a setting, then a second after changing the setting and then using diff (often with -C10 to give me context, or use meld or your fav. visual diff program) to see what changed.
Thanks for the help Michael. Thatās just an insane and un-friendly way to have to configure hotkeys for anyone! If thatās the only way iāll run with it, seems insane.
Itās given me some limited clues, thank you. Iāll keep investigating.
Kyle.
Thank you for that feedback, Kyle! Itās certainly not an intuitive process for an end user to configure. Iām relaying your frustration to our product team.
Thanks,
Alexa
Thanks Alexaz!
Hello, how would I go about adding a shortcut to cycle the stack backwards? Iām adapting the code from above but Iām getting an error
"ERROR: āmoduleā object has no attribute ācycleStackBackwardā
below is the code that Iām using in rvrc.py.
from rv import rvui, commands, extra_commands
def initialize():
rvui.defineDefaultBindings()
return rvui.newStateObject()
def setup():
def cycle(Event):
rvui.cycleStackBackward()
commands.bind("default", "global", "key-down--q", cycle, "Play")
return
rvui isnāt a ābuilt-inā module, so the functions arenāt automatically bound to Python, you probably want to do something like:
from PyMu import MuSymbol
cycle_backward = MuSymbol('rvui.cycleStackBackward')
then in your cycle() method:
cycle_backward(event)
(If you look at the rvui.mu code, youāll see that needs an event, alternatiely you can bind directly to it, or use smartCycleInputs
with a bool.
Hello,
How would I make a shortcut to show and hide annotations?
Thanks
Hi, i know nothing about scripting python but can anyone help meā¦ i want to change keybinding for āStep Forward 1 Frameā and āMove Back One Frameā. iāve tried to write but nothing happen T_T
from rv import rvui, commands, extra_commands
def initialize():
rv.rvui.defineDefaultBindings()
return rv.rvui.newStateObject();
def setup():
def eventMoveBackOneFrame(event):
extra_commands.MoveBackOneFrame()
commands.bind("default", "key-down--alt--z", eventMoveBackOneFrame, "MoveBackOneFrame")
return