You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多
文档控制台
免费开始使用

如何在The Foundry NUKE中直接为函数绑定快捷键(无需菜单配置)

Directly Bind a Shortcut to Your Function in NUKE

Got it, you want to skip the whole menu setup and bind alt+u straight to do_This.doThis()—no problem. NUKE has a dedicated API method for this that bypasses menu configuration entirely.

Here's the code you need:

# First make sure your module is imported
import do_This

# Optional: Clear any existing shortcut for alt+u to avoid conflicts
nuke.removeShortcut('alt+u')

# Bind the shortcut directly to your function
nuke.addShortcut('alt+u', do_This.doThis)

A quick breakdown:

  • nuke.addShortcut() is the key here—it lets you map a keyboard shortcut directly to a function without needing to add it to a menu first.
  • Pass the shortcut string (alt+u) as the first argument, and your function reference (do_This.doThis, no parentheses!) as the second.
  • The nuke.removeShortcut() line is optional but recommended if you've previously bound this shortcut via a menu or another script, to prevent unexpected behavior.

To make this stick every time NUKE launches, drop this code into your init.py or menu.py file located in your .nuke directory (usually ~/.nuke/ on Linux/macOS, or C:\Users\[YourUsername]\.nuke\ on Windows).

内容的提问来源于stack exchange,提问作者Matteugi

火山引擎 最新活动