paintNodeOpacity.py
paintNodeOpacity python code
This little code will help you to control nuke "rotopaint" nodes clone & paint brush opacity via some short-cut keys. I created this code for my fellow artist who's working with me in paint department.
Short-cut keys are assigned as per his need. You can use your custom short-cut keys.
There are 5 control option.
"shift+>", "shift+<"
user can up & down the opacity value using "shift+>" and "shift+<". This will jump between current value to +0.05 or -0.05.
If your value will 1 it start to decrease 0.95, 0.9, 0.85 so one so forth....
"ctrl+>", "ctrl+<"
user can up & down the opacity value using "ctrl+>" and "ctrl+<". This will jump between current value to +0.01 or -0.01.
If your value will 1 it start to decrease 0.99, 0.98, 0.97 so one so forth....
"ctrl+Shift+<" and "ctrl+Shift+<"
This will return the opacity value to default 1 and 0.
Hope this will help you guys.
updated Aug19th: Fixed NameError:. In previous version, while user accidentally hit these short-cut nuke will pop-up the name error. This issue fixed now and removed "please select rotopaint node" message.
Download: paintOpacity.py
else: copy paste below code:
'''
Created on 07-august-2013
@author: satheesh-R
mail - satheesrev@gmail.com
'''
import nuke, math, os
def paintOpacityUp():
selNode = None
try:
selNode = nuke.selectedNode()
except ValueError: # no node selected
pass
cls = selNode.Class()
if cls == 'RotoPaint':
for a in nuke.selectedNodes():
getValue = a['toolbar_opacity'].value()
newValue = sorted([0, getValue + 0.05, 1])[1]
setVal = a['toolbar_opacity'].setValue(newValue)
else:
return
def paintOpacityUpIncrease():
selNode = None
try:
selNode = nuke.selectedNode()
except ValueError: # no node selected
pass
cls = selNode.Class()
if cls == 'RotoPaint':
for a in nuke.selectedNodes():
getValue = a['toolbar_opacity'].value()
newValue = sorted([0, getValue + 0.01, 1])[1]
setVal = a['toolbar_opacity'].setValue(newValue)
else:
return
def paintOpacityDown():
selNode = None
try:
selNode = nuke.selectedNode()
except ValueError: # no node selected
pass
cls = selNode.Class()
if cls == 'RotoPaint':
for a in nuke.selectedNodes():
getValue = a['toolbar_opacity'].value()
newValue = getValue - 0.05
if newValue < 0: newValue = 0
setVal = a['toolbar_opacity'].setValue(newValue)
else:
return
def paintOpacityDecrease():
selNode = None
try:
selNode = nuke.selectedNode()
except ValueError: # no node selected
pass
cls = selNode.Class()
if cls == 'RotoPaint':
for a in nuke.selectedNodes():
getValue = a['toolbar_opacity'].value()
newValue = getValue - 0.01
if newValue < 0: newValue = 0
setVal = a['toolbar_opacity'].setValue(newValue)
else:
return
def paintOpacityDefault():
selNode = None
try:
selNode = nuke.selectedNode()
except ValueError: # no node selected
pass
cls = selNode.Class()
if cls == 'RotoPaint':
for a in nuke.selectedNodes():
a['toolbar_opacity'].setValue(1)
else:
return
def paintOpacityZero():
selNode = None
try:
selNode = nuke.selectedNode()
except ValueError: # no node selected
pass
cls = selNode.Class()
if cls == 'RotoPaint':
for a in nuke.selectedNodes():
a['toolbar_opacity'].setValue(0)
else:
return
_______________________________________________
menu.py
import paintOpacity
menuBar = nuke.menu("Nuke")
menuBar.addCommand('Edit/Node/paintOpacity/Up', 'paintOpacity.paintOpacityUp()', 'shift+>')
menuBar.addCommand('Edit/Node/paintOpacity/Down', 'paintOpacity.paintOpacityDown()', 'shift+<')
menuBar.addCommand('Edit/Node/paintOpacity/increase', 'paintOpacity.paintOpacityUpIncrease()', 'ctrl+.')
menuBar.addCommand('Edit/Node/paintOpacity/decrease', 'paintOpacity.paintOpacityDecrease()', 'ctrl+,')
menuBar.addCommand('Edit/Node/paintOpacity/default', 'paintOpacity.paintOpacityDefault()', 'ctrl+shift+>')
menuBar.addCommand('Edit/Node/paintOpacity/zero', 'paintOpacity.paintOpacityZero()', 'ctrl+shift+<')
Comments
Post a Comment