Assigning Custom hotkey to a python function

   7438   5   0
User Avatar
Member
52 posts
Joined: 6月 2009
Offline
Hello everyone,

How to assign a hotkey (keyboard shortcut) to a python function defined inside an OTL.? I tried searching the documentation and forum regarding this but i couldnt find it out. Kindly help me out with this.

Thanks a lot in advance.
User Avatar
Member
1921 posts
Joined: 11月 2006
Offline
You can't map a hotkey directly to a function. You need some sort of tool/action. Your best bet would be to create a tool that calls your Python function and then you can assign a hotkey to that particular tool.

http://www.sidefx.com/docs/houdini11.0/ref/windows/edittool [sidefx.com]
http://www.sidefx.com/docs/houdini11.0/ref/windows/hotkey [sidefx.com]
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
52 posts
Joined: 6月 2009
Offline
Thanks a lot for such a quick reply Graham. I ll go through these links and get back to you.
User Avatar
Member
52 posts
Joined: 6月 2009
Offline
Sorry for the late reply Graham.

Assinging hotkey to a tool that calls the function worked like a charm. But tell me, is it not possible to store these hotkey settings within a digital asset.?
User Avatar
Member
1921 posts
Joined: 11月 2006
Offline
Unfortunately hotkey data can't be stored with assets. Hotkey data is stored in a file called HotkeyOverrides which is saved somewhere in your Houdini path, usual your $HOME/houdiniX.Y directory. Even if you create another tool attached to your digital asset and assign a hotkey through the Type Properties you will only get that hotkey available on your user/machine you created it on. The moment someone else loads that asset it won't have a hotkey associated with it.

You could consider writing a OnLoaded handler for your digital asset and in there, use hou.findFile() to look for the HotkeyOverrides file and append the necessary override code into that file if it isn't already in there. However the hotkey added with that method will work until the next time you launch Houdini because Houdini doesn't refresh its hotkey list.
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
899 posts
Joined: 2月 2016
Offline
I was wondering if now the following method is supported:

OnLoaded, a digital asset temporally assigns an hotkey to a python function.
The hotkey would launch a function inside the otl (10 frames jump in the timeline).
Then OnDeleted the original hotkey is restored.

cheers
  • Quick Links