Custom Scripts I: Quick value changers

These two scripts allow to change the value of a certain knob to a selection of nodes or to all nodes of a certain class.

Change value to a class:

def change_all_class():
    change_all_panel = nuke.Panel('Change value to a class')
    change_all_panel.addSingleLineInput('Node class', '')
    change_all_panel.addSingleLineInput('Knob', '')
    change_all_panel.addSingleLineInput('Value', '')
    if not change_all_panel.show():
        return
    panel_node = change_all_panel.value('Node class')
    panel_knob = change_all_panel.value('Knob')
    panel_value = int(change_all_panel.value('Value'))
    for node in nuke.allNodes(panel_node):
        node[panel_knob].setValue(panel_value)

You can launch this script just copying it in Nuke’s Script Editor and executing this command:

change_all_class()

Or you can create a custom menu to store this script by copying the script in the menu.py and adding this code line after the script:

nuke.menu('Nuke').addCommand('Custom Scripts/Change value to a class', 'change_all_class()')
Change value to a selection:

def change_all_selection():
    change_all_panel = nuke.Panel('Change value to a selection')
    change_all_panel.addSingleLineInput('Knob', '')
    change_all_panel.addSingleLineInput('Value', '')
    if not change_all_panel.show():
        return
    panel_knob = change_all_panel.value('Knob')
    panel_value = int(change_all_panel.value('Value'))
    for node in nuke.selectedNodes():
        node[panel_knob].setValue(panel_value)

You can launch this script just copying it in Nuke’s Script Editor and executing this command:

change_all_selection()

Or you can create a custom menu to store this script by copying the script in the menu.py and adding this code line after the script:

nuke.menu('Nuke').addCommand('Custom Scripts/Change value to a selection', 'change_all_selection()')

 

If you need any help or you want to make any suggestion, please feel free to contact me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.