### python code written by Martin Viel www.martinviel.com ### #codes for the GO! buttons def cloneCode() : #apply the change to all nodes or only selected nodes? node_list = set() if nuke.thisNode()['clone_all_or_selected'].getValue() == 0 : node_list = set(nuke.allNodes('Read')) nuke.selectAll() nuke.invertSelection() if nuke.thisNode()['clone_all_or_selected'].getValue() == 1 : for s in nuke.selectedNodes() : if s.Class() == 'Read' : node_list.add(s) nuke.selectAll() nuke.invertSelection() #create a list of paths path_list=set() for n in node_list : path_list.add(n['file'].value()) #for each path, create a list of node to force clone selection_node_list = set() for path in path_list : group_clone = set() for n in node_list : if n['file'].value() == path : group_clone.add(n) #force clone the list of nodes if len(group_clone) >=2 : for n in group_clone : n.setSelected(True) nuke.forceClone() #will the node remain selected at the end? if len(group_clone) >= 2 : for s in set(nuke.selectedNodes()) : selection_node_list.add(s) if len(group_clone) == 1 : for s in group_clone : selection_node_list.add(s) node_list -= group_clone nuke.selectAll() nuke.invertSelection() #select the nodes remaining selected for n in selection_node_list : n.setSelected(True) def colorspaceCode() : #apply the change to all nodes or only selected nodes? node_list = set() if nuke.thisNode()['colorspace_all_or_selected'].getValue() == 0 : node_list = set(nuke.allNodes('Read')) nuke.selectAll() nuke.invertSelection() if nuke.thisNode()['colorspace_all_or_selected'].getValue() == 1 : for s in nuke.selectedNodes() : if s.Class() == 'Read' : node_list.add(s) nuke.selectAll() nuke.invertSelection() #create a list of stmap Read dependencies_list = set() for n in nuke.allNodes('STMap') : dependencies_list.add(n.input(1)) node_connectedto_stmap_list = dependencies_list while dependencies_list : new_dependencies_list = set() for d in dependencies_list : e = set(d.dependencies()) new_dependencies_list.update(e) dependencies_list = new_dependencies_list node_connectedto_stmap_list.update(new_dependencies_list) Readstmap_list = node_connectedto_stmap_list & node_list for n in node_list : if 'stmap' in n['file'].value() : Readstmap_list.add(n) #change colorspace if nuke.thisNode()['stmap'].value() == True : node_list -= Readstmap_list for n in node_list : n['colorspace'].setValue(nuke.thisNode()['colorspace'].value()) #select the nodes remaining selected nuke.selectAll() nuke.invertSelection() for n in node_list : n.setSelected(True) #message if nuke.thisNode()['colorspace_all_or_selected'].getValue() == 0 : all_or_selected = 'All' if nuke.thisNode()['colorspace_all_or_selected'].getValue() == 1 : all_or_selected = 'All selected' colorspace = nuke.thisNode()['colorspace'].value() stmap_name_list = set() for n in Readstmap_list : stmap_name_list.add(n.name()) if Readstmap_list : stmap = """, except for these STMap : - %s""" % ('\n- '.join(stmap_name_list)) else : stmap = '.' if nuke.thisNode()['stmap'].value() == True : nuke.message(""" %s Read nodes have been changed to %s%s """ % (all_or_selected, colorspace, stmap)) def localizeCode() : #apply the change to all nodes or only selected nodes? node_list = set() if nuke.thisNode()['localize_all_or_selected'].getValue() == 0 : node_list = set(nuke.allNodes('Read')) nuke.selectAll() nuke.invertSelection() if nuke.thisNode()['localize_all_or_selected'].getValue() == 1 : for s in nuke.selectedNodes() : if s.Class() == 'Read' : node_list.add(s) nuke.selectAll() nuke.invertSelection() #change localization policy for n in node_list : n['localizationPolicy'].setValue(nuke.thisNode()['localize'].value()) #select the nodes remaining selected nuke.selectAll() nuke.invertSelection() for n in node_list : n.setSelected(True) ####################################################### #jump def jump() : jump = nuke.Text_Knob('divider line','') node.addKnob(jump) #text def text(instructions) : text = nuke.Text_Knob('text','') text.setValue(instructions) node.addKnob(text) #all or selected button def all_or_selected(name) : allorselected_pulldown = nuke.Enumeration_Knob(name, 'Apply to', ('all nodes', 'selected nodes')) node.addKnob(allorselected_pulldown) #GO! button def go(code) : go_button = nuke.PyScript_Knob('','GO!', code) node.addKnob(go_button) ####################################################### #create the Node node = nuke.nodes.NoOp(name='READ CCL') #create clone buttons text('Find similar nodes and create clones :') all_or_selected('clone_all_or_selected') go('cloneCode()') #create colorspace buttons jump() text('Change colorspace of multiples nodes :') list_of_colorspaces = nuke.root()['int16Lut'].values() colorspace_pulldown = nuke.Enumeration_Knob('colorspace','colorspace', list_of_colorspaces) colorspace_pulldown.setValue(nuke.root()['int16Lut'].value()) node.addKnob(colorspace_pulldown) stmap_box = nuke.Boolean_Knob('stmap', 'exclude STMap') stmap_box.setValue(True) node.addKnob(stmap_box) all_or_selected('colorspace_all_or_selected') go('colorspaceCode()') #create localize buttons jump() text('Change localization policy of multiples nodes :') selected_node_list = nuke.selectedNodes() nuke.selectAll() nuke.invertSelection() r = nuke.createNode('Read') list_of_localizations = r.knob('localizationPolicy').values() localize_pulldown = nuke.Enumeration_Knob('localize','localization', list_of_localizations) node.addKnob(localize_pulldown) nuke.delete(nuke.selectedNode()) nuke.selectAll() nuke.invertSelection() for s in selected_node_list : s.setSelected(True) all_or_selected('localize_all_or_selected') go('localizeCode()') ### python code written by Martin Viel www.martinviel.com ###