Beispiel #1
0
def hub_updateSelectedNodes():
    #This function changes the current selected node to the given shot only if that layer exists and updates to the latest version
    #Args None
    #Returns None
    win = hub_updateSelectedNodes_UI()
    if win.showModalDialog():
        shot_new = win.typeKnob.value()
        #Store the job's information on shots
        job_shots = envPaths.mpc_getShotList()
        job_shots_list = envPaths.mpc_getShotList(dict=False)
        rogueNodes = []
        #if the new shot is in the list of shots for the job...
        if shot_new in job_shots_list:
            for node in nuke.selectedNodes():
                #if the selected object is a hubRead...
                if node.knob('shot') and node.knob('layerVersion'):
                    #Record all of the default settings
                    shot_current = node['shot'].value()
                    layer_current = node['layer'].value()
                    pass_current = node['pass'].value()
                    version_current = node['layerVersion'].getValue() #getting this just in case
                    layer_new = layer_current.replace(shot_current, shot_new)
                    
                    # if it's the shot is the same as the current node do nothing
                    if not shot_current == shot_new:
                        #actually change shit if the layer_new is in the elements folder
                        elementsList = envPaths.mpc_elementsList(shot_new)
                        if layer_new in elementsList:
                            #now finally check out if the same passes exist... or if we even need to
                            elementsMatch= [ele for ele in elementsList if layer_new in ele]
                            if envPaths.mpc_passesList(shot_new, (layer_new+'_v'+str(len(elementsMatch) + 1 )), pass_current) or pass_current == 'N/A':
                                #let's check if the sequence is correct, if it's not, correct.
                                seq_new=None
                                for key in job_shots.keys():
                                    if shot_new in job_shots[key]:
                                        seq_new = key
                                if seq_new:
                                    node['scene'].setValue(seq_new) 
                                #update the node just in case it isn't in the shot list from old nodes...but we know these things exist so it's fine
                                if not shot_new in node['shot'].values():
									node['updt'].execute()
                                #If the shot is in the list, go for it!
                                if shot_new in node['shot'].values():
                                    node['shot'].setValue(shot_new)
                                    #set the layer version to the latest version
                                    node['layerVersion'].setValue( node['layerVersion'].values()[0] )
                                    #Set the pass and layer if they exist in the pass/layer fields
                                    if layer_new in node['layer'].values():
                                        node['layer'].setValue(layer_new)
                                    if pass_current in node['pass'].values():
                                        node['pass'].setValue(pass_current)
                                else:
                                    shots = '\n'.join(node['shot'].values())
                                    print('Sorry...that shot doesn\'t exist on your node %s\nPossible inputs are:\n%s'%(node.name(), shots), sys.stderr)
                                    rogueNodes.append(node.name())
                            else:
                                print('Pass %s was not found in element %s in shot %s...skipping'%(pass_current, layer_new, shot_new), file=sys.stderr)
                                rogueNodes.append(node.name())
                        else:
                            print('No element matching [%s--%s] in shot %s as element %s...skipping'%(layer_current, pass_current, shot_new, layer_new), file=sys.stderr)
                            rogueNodes.append(node.name())
                    else:
                        print('The shot is identical! Not doing a gosh darn thing...skipping node %s'%node.name(), file=sys.stderr)
                else:
                    print('Node %s is not a hub node...skipping'%node.name(), file=sys.stderr)
        else:
            nuke.message("Shot %s does not exist in this job...sorry."%shot_new)
        print('List of nodes not changed:\n%s'%'\n\t'.join(rogueNodes), file=sys.stderr)
Beispiel #2
0
 def __init__(self):
     nukescripts.PythonPanel.__init__(self, 'Update Selected Hub Read Nodes')
     self.typeKnob = nuke.Enumeration_Knob('shot',
                                                      'Shot to switch to',
                                                      envPaths.mpc_getShotList(dict=False))
     self.addKnob(self.typeKnob)