Last active
May 9, 2018 05:38
-
-
Save BenMcEwan/ce3d4650a8aa985ee829ad244da10c52 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -------------------------------------------------------------- | |
# ViewerChangeToggle.py | |
# Version: 1.0.0 | |
# Last Updated: January 11th, 2018 | |
# -------------------------------------------------------------- | |
# -------------------------------------------------------------- | |
# USAGE: | |
# | |
# Shift+Home will toggle your Viewer Exposure & Gamma between it's changed state & default value. | |
# All credit goes to Ben Dickson for helping me figure this out! | |
# Add this to menu.py | |
# -------------------------------------------------------------- | |
_viewer_prev_settings = {'gain': 1, 'gamma': 1} | |
def reset_expose_gain(): | |
global _viewer_prev_settings | |
# Get magic ViewerWindow node | |
viewer = nuke.activeViewer() | |
# Get regular Viewer node which contains | |
# exposure knob and such | |
node = viewer.node() | |
curgain = node['gain'].value() | |
curgamma = node['gamma'].value() | |
if curgain != 1.0 or curgamma != 1.0: | |
# Values are non-default, store them in memory | |
_viewer_prev_settings['gain'] = curgain | |
_viewer_prev_settings['gamma'] = curgamma | |
# Reset to defaults | |
node['gain'].setValue(1) | |
node['gamma'].setValue(1) | |
else: | |
# Values are default, restore previous settings if any | |
node['gain'].setValue(_viewer_prev_settings['gain']) | |
node['gamma'].setValue(_viewer_prev_settings['gamma']) | |
m_viewer = nuke.menu("Viewer") | |
m_viewer.addCommand("Zero Viewer", reset_expose_gain, "shift+home") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment