python scripts for daily work on nuke
I'm updating regularly this post with "Tiny, Tiny " python scripts for daily uses in nuke.
1. For define roto nodes output.
Usually we set the roto node output to "alpha" and premultiply to "rgb" for getting the premultiplied output. like below image:
rotoOut python script:
This script will do this work by a single mouse click are a short-cut key.
rotoOut python script:
This script will do this work by a single mouse click are a short-cut key.
import nuke
def rotoOut():
for s in nuke.selectedNodes():
s['output'].setValue('alpha')
s['premultiply'].setValue('rgb')
save this as rotoOut.py file into your custom python or gizmo DIR.
This script works only selected roto nodes. If you want to make it work with all roto nodes in inside nuke means, youe need to change the 3rd line like this...
import nuke
def rotoOut():
for s in nuke.allNodes('Roto'):
s['output'].setValue('alpha')
s['premultiply'].setValue('rgb')
2. Shuffle the image based matte to alpha channel.
Usually nuke consider single channel as red channel inside the nuke. If you import single channel image files into nuke, nuke display the channel onto the red channel only. We need to do shuffle the the "red" to "alpha" for get alpha channel from the image based matte files.
This little py script will do this for us:
import nuke
def shuffleRedOnly():
s1 = nuke.createNode('Shuffle')
s1['red'].setValue('red')
s1['green'].setValue('red')
s1['blue'].setValue('red')
s1['alpha'].setValue('red')
save this as shuffleRedOnly().py file into your custom python or gizmo DIR.
3. Disable nodes via expression.
Disable a node in nuke between frames is help you lot off time. Put this expression on the disable knob off any node in nuke and it will automatically disable the nodes on the mentioned frames before and after.
Below expression for in between two values:
Only for before:
You can assign this via script editor by following python command:
3. Disable nodes via expression.
Disable a node in nuke between frames is help you lot off time. Put this expression on the disable knob off any node in nuke and it will automatically disable the nodes on the mentioned frames before and after.
Below expression for in between two values:
frame < 10 || frame >20
Only for before:
frame < 10
Only for after:
frame >20
You can assign this via script editor by following python command:
for s in nuke.selectedNodes():
s['disable'].setValue("frame < 10 || frame > 20")
4. Reload read nodes.
When working with CG (3D) compositing, Inputs are updated regularly by new version or overwritten. 3D artist says to you, hey i overwritten the files with new render. So we need to reload all the read nodes. This little code will reload all the read nodes at a time.
[s.knob('reload').execute() for s in nuke.allNodes() if s.Class=='Read']
or
for s in nuke.allNodes('Read'):
s['reload'].execute()
5. Disable all the Denoise node inside nuke.
(Denoise node having different Class name)
For find the nodes Class name ( like Denoise node, it has different Class ) use following command.
s['reload'].execute()
5. Disable all the Denoise node inside nuke.
(Denoise node having different Class name)
for s in nuke.allNodes("OFXuk.co.thefoundry.noisetools.denoise_v100"):
s['disable'].setValue(1)
|
For find the nodes Class name ( like Denoise node, it has different Class ) use following command.
a = nuke.selectedNode()
print a.Class()
|
Comments
Post a Comment