예제 #1
0
def stuffSuffer_auto():
    """
    auto create suffer .....
    :return:
    ben
    """
    read_node = nuke.selectedNodes('Read')
    for ea_rd in read_node:
        #ea_rd = read_node[0]
        nuke.autoplace(ea_rd)
        chnls = ea_rd.channels()
        lys = list(set([ech.split('.')[0] for ech in chnls]))
        px,py = ea_rd.xpos(),ea_rd.ypos() + 105
        ea_rd.setSelected(False)
        h_bias = 140
        v_bias = 40
        shuf_1=nuke.nodes.Shuffle()
        shuf_1['in'].setValue(lys[0])
        shuf_1.setInput(0,ea_rd)
        #shuf_1['hide_input'].setValue(True)
        shuf_1.setName("{}_".format(lys[0]))
        #shuf_1.knob('label').setValue("ExShf_{}_{}".format(ea_rd.name().upper(),foundLy[i]))
        shuf_1.setXYpos(px,py)
        shuf_1.setSelected(True)
        sel_shf_nm = len(nuke.selectedNodes("Shuffle"))
    for ea in nuke.selectedNodes(): ea.setSelected(False)
 def MergRGBChannel():

    # Create Merge RGB Channel
	MergeRGB = nuke.createNode("Merge2", inpanel = False)
	MergeRGB['operation'].setValue('max')
	MergeRGB = nuke.selectConnectedNodes()
	for MergeRGB in nuke.selectedNodes():
	    nuke.autoplace(MergeRGB)
	nuke.selectAll()
예제 #3
0
def copyPremult():

    n = nuke.createNode('Copy')
    m = nuke.createNode('Premult')

    n['selected'].setValue(True)
    m['selected'].setValue(True)

    sel = nuke.selectedNodes()
    for i in sel:
        nuke.autoplace(i)

    nukescripts.clear_selection_recursive()
예제 #4
0
def main():
    origin_nodes = nuke.selectedNodes()
    origin_nodes.sort(key=lambda x: x.xpos())
    for node in origin_nodes:
        nuke.autoplace(node)
    nodes = nuke.selectedNodes()
    nodes.sort(key=lambda x: x.xpos())

    current_xpos_list = [node.xpos() for node in nodes]

    count = 0
    for node_x in current_xpos_list:
        print node_x
        if count == 0:
            origin_nodes[count].setXpos(node_x)
        else:
            origin_nodes[count].setXpos(node_x + 150 * count)
        print count
        count += 1
예제 #5
0
    def create(self):
        for i, info in enumerate(self.infos):

            self.shot_code = info[0]
            self.base_path = info[1]

            cmps = self.get_comp()
            nuke.selectAll()
            nuke.invertSelection()
            for cmp in cmps:
                cmp['selected'].setValue(True)
                nuke.autoplace(cmp)
            #nuke.autoplace_all()
            #_autoplace()

            x = autoBackdrop.autoBackdrop()
            x['bdheight'].setValue(x['bdheight'].value() + 100)
            x['ypos'].setValue(x['ypos'].value() - 50)
            nuke.selectAll()
            nuke.invertSelection()

            p = self.get_plate()
            p['xpos'].setValue(x['xpos'].value() + 20)
            p['ypos'].setValue(x['ypos'].value() + 20)
            c = self.get_cutref()
            if c:
                c['xpos'].setValue(p['xpos'].value() + 100)
                c['ypos'].setValue(p['ypos'].value())
                c['selected'].setValue(True)
            p['selected'].setValue(True)

            x['label'].setValue(self.shot_code)
            x['ypos'].setValue(x['ypos'].value() - 40)
            x['bdheight'].setValue(x['bdheight'].value() + 40)
            #print nuke.selectedNode()['tile_color'].value()
            if i % 2:
                x['tile_color'].setValue(1431655935)
            else:
                x['tile_color'].setValue(2088533247)
예제 #6
0
 def autocropLayers(self, first=None, last=None, inc=None, layer="rgba"):
     
     root = nuke.root()
     if first is None:
         first = int(root.knob("first_frame").value())
     if last is None:
         last = int(root.knob("first_frame").value())
     if inc is None:
         inc = 1
     original_nodes = nuke.selectedNodes()
     all_nodes = nuke.allNodes()
     for i in all_nodes:
         i.knob("selected").setValue(False)
     for i in original_nodes:
         i.knob("selected").setValue(True)
         autocropper = nuke.createNode("CurveTool", '''operation 0 ROI {0 0 input.width input.height} Layer %s label "Processing Crop..." selected true''' % (str(layer), ), False)
         nuke.executeMultiple([autocropper,], ([first, last, inc],))
         autocropper.knob("selected").setValue(True)
         cropnode = nuke.createNode("Crop", "label AutoCrop", False)
         cropbox = cropnode.knob("box");
         autocropbox = autocropper.knob("autocropdata");
         cropbox.copyAnimations(autocropbox.animations())
         cropnode.knob("indicators").setValue(1)
         all_nodes = nuke.allNodes()
         for j in all_nodes:
             j.knob("selected").setValue(False)
         autocropper.knob("selected").setValue(True)
         nukescripts.node_delete()
         all_nodes = nuke.allNodes()
         for j in all_nodes:
             j.knob("selected").setValue(False)
         nuke.autoplace(cropnode)
         cropnode.knob("selected").setValue(True)
         cropnode.knob("reformat").setValue(True)
         nuke.autoplace(cropnode)
         
     return cropnode
예제 #7
0
def tri_writeGizmo_init():
    nuke.tprint("  START TriWrite")
    if not 'triwrite_gizmo' in nuke.thisNode().knobs():
        return
    
    nuke.thisNode()['artist'].setValue(artistName())

    if nuke.thisNode()['notes'].value() == "":
        nuke.thisNode()['notes'].setValue(sceneComment())
    
    if not 'tri_project_xml_formats' in nuke.root().knobs():
        return
    
    nuke.tprint("  INIT ", nuke.thisNode().name(), nuke.thisNode().Class())
    
    root = nuke.root()
    pData = etree.fromstring(root['tri_project_xml_formats'].value())
    nuke.thisNode()['_dailies_format'].setValue(root['tri_project_id'].value() + " DAILIES")
    
    if 'tri_project_scene_id' in root.knobs():
        # create write dis
        tri_create_write_path(pData.find('result'))
        tri_create_write_path(pData.find('dailies'))
        # setup results/dailies params
        tri_filename_init(nuke.thisGroup().node('result'), pData.find('result'))
        tri_filename_init(nuke.thisGroup().node('dailies'), pData.find('dailies'))
        
        nuke.thisGroup()['_render'].setEnabled(True)
        nuke.thisGroup()['write_result'].setEnabled(True)
        nuke.thisGroup()['write_dailies'].setEnabled(True)
        nuke.thisGroup()['slate'].setEnabled(True)
    
    if nuke.thisGroup().inputs > 0:
        nuke.autoplace(nuke.thisGroup())
    
    pData = None
예제 #8
0
def _autoplace():
    n = nuke.selectedNodes()
    for i in n:
        nuke.autoplace(i)
예제 #9
0
def MultiChannelCombine():

    images = nuke.selectedNodes()
    passes = []
    passesRename = []
    lastPass = ""
    pipe2 = ""
    i = 0
    noread = 0
    inputReads = []

    if len(images) > 1:

        #check if all selected nodes are read nodes
        imageIn = ""
        for img in images:

            if img.Class() != "Read":
                noread += 1

        if noread == 0:

            for img in images:

                #get file path
                readPath = img["file"].value()
                #split by "/" to get the image name
                readPathArr = readPath.split("/")
                #image name is last item of arr
                imageName = readPathArr[len(readPathArr) - 1]
                #cut ending (.jpg, .png, .exr, etc...)
                imageRawArr = imageName.split(".")
                imageRawArr.pop()
                imageRaw = "".join(imageRawArr)
                #cut padding %05d etc...
                if "%" in imageRaw:
                    temp = imageRaw.split("%")
                    imageRaw = temp[0]

                #cut "_" , "." and "-" if that is the last character
                if imageRaw != "":
                    if imageRaw[(len(imageRaw) - 1)] == "_" or imageRaw[(
                            len(imageRaw) -
                            1)] == "." or imageRaw[(len(imageRaw) - 1)] == "-":
                        imageRaw = imageRaw[:-1]

                inputReads.append(imageRaw)

            p = createPanel(inputReads)

            renamed = setLayerList(inputReads)

            if p.show():

                channelNames = []
                temp = 0
                for cn in inputReads:
                    channelNames.append(p.value(inputReads[temp]))
                    temp += 1

                #check if all channels have a name
                isEmpty = 0
                allUnder30Char = 0
                for c in channelNames:
                    if c == "":
                        isEmpty += 1
                    if len(c) > 30:
                        allUnder30Char += 1

                if isEmpty > 0:
                    nuke.message("you haven't named all channels.")
                    MultiChannelCombine()

                else:

                    if allUnder30Char == 0:
                        for img in images:

                            #autoplace selected nodes
                            nuke.autoplace(img)

                            #get all the filenames to use them as pass name
                            imagePath = img.knob("file").value()
                            imageSplit = imagePath.split("/")
                            lastVal = imageSplit.pop()
                            #cutouts
                            lastVal = lastVal.split(".")
                            passName = lastVal[0]
                            #frame padding %
                            lastVal = passName.split("%")
                            passName = lastVal[0]
                            passes.append(passName)

                            #creating channels
                            r_temp = channelNames[i] + ".red"
                            g_temp = channelNames[i] + ".green"
                            b_temp = channelNames[i] + ".blue"
                            a_temp = channelNames[i] + ".alpha"

                            newLayer = nuke.Layer(
                                channelNames[i],
                                [r_temp, g_temp, b_temp, a_temp])

                            if i == 0:
                                shuffle1 = nuke.nodes.Shuffle()
                                shuffle1.setName("shuffle_%s" %
                                                 channelNames[i])
                                shuffle1.setInput(0, images[0])

                                #setting up the shuffle nodes inputs and outputs
                                shuffle1.knob("out").setValue(channelNames[i])

                            if i > 0:
                                if i == 1:
                                    #initialize pipe2 for first round
                                    pipe2 = shuffle1

                                #creating shuffle
                                shuffle = nuke.nodes.ShuffleCopy()

                                shuffle.setName("shuffle_%s" % channelNames[i])
                                shuffle.setInput(0, pipe2)
                                shuffle.setInput(1, images[i])

                                #setting up the shuffle nodes inputs and outputs
                                shuffle.knob("out2").setValue(channelNames[i])

                                shuffle['red'].setValue('red2')
                                shuffle['green'].setValue('green2')
                                shuffle['blue'].setValue('blue2')
                                shuffle['alpha'].setValue('alpha2')

                                shuffle['black'].setValue('red')
                                shuffle['white'].setValue('green')
                                shuffle['red2'].setValue('blue')
                                shuffle['green2'].setValue('alpha')

                                #this was a reported bug;
                                #it's right that red2 is actually called black, green2 is actually called white, blue2 is actually called red2 and alpha2 is actually called green2
                                #pretty strange but it is like that
                                #look here:
                                #http://forums.thefoundry.co.uk/phpBB2/viewtopic.php?t=5954&sid=5eba0be48c454bf34bc7bdf301983a21

                                #safe last shuffle for next round to pipe it in in shuffleknob pipe2
                                pipe2 = shuffle

                            i += 1

                        #create metadata-tag when comment was set
                        lastShuffle = nuke.toNode(
                            "shuffle_" + channelNames[len(channelNames) - 1])
                        commentVal = ""
                        commentVal = p.value("comment (optional): ")
                        if commentVal != "":
                            md = nuke.nodes.ModifyMetaData()
                            md.knob("metadata").fromScript(
                                "{set comment %s}" %
                                commentVal.replace(" ", "_"))
                            md.setName("comment")
                            md.setInput(0, lastShuffle)

                        #create write node
                        write = nuke.nodes.Write()
                        write.knob("file_type").setValue("exr")
                        write.knob("compression").setValue(
                            "Zip (16 scanlines)")
                        write.knob("channels").setValue("all")
                        if commentVal != "":
                            write.setInput(0, md)
                            write.knob("metadata").setValue("all metadata")
                        else:
                            write.setInput(0, lastShuffle)

                    else:
                        nuke.message(
                            "Wait, the channel names are too long. Pleae make sure, that each channel name is under 30 characters long. Otherwise the exr does not work properly."
                        )

        else:
            nuke.message("Please make sure to select READ nodes only")
    else:
        nuke.message("Please select at least 2 Read Nodes")
예제 #10
0
 def autoplace(self, nodes):
     for node in nodes:
         nuke.autoplace(node)
예제 #11
0
def MultiChannelCombine():

    images = nuke.selectedNodes()
    passes=[]
    passesRename=[]
    lastPass=""
    pipe2=""
    i=0
    noread=0
    inputReads=[]
    
    if len(images)>1:
        
        #check if all selected nodes are read nodes
        imageIn=""
        for img in images:
            
            if img.Class()!="Read":
                noread+=1

        if noread==0:
            
            for img in images:
                
                #get file path
                readPath=img["file"].value()
                #split by "/" to get the image name
                readPathArr=readPath.split("/")
                #image name is last item of arr
                imageName=readPathArr[len(readPathArr)-1]
                #cut ending (.jpg, .png, .exr, etc...)
                imageRawArr = imageName.split(".")
                imageRawArr.pop()
                imageRaw = "".join(imageRawArr)   
                #cut padding %05d etc...
                if "%" in imageRaw:
                    temp=imageRaw.split("%")
                    imageRaw=temp[0]
                
                #cut "_" , "." and "-" if that is the last character
                if imageRaw!="":
                    if imageRaw[(len(imageRaw)-1)]=="_" or imageRaw[(len(imageRaw)-1)]=="." or imageRaw[(len(imageRaw)-1)]=="-" :
                       imageRaw=imageRaw[:-1]
                    
                inputReads.append(imageRaw)
                
            
            
            p = createPanel(inputReads)
           
            renamed = setLayerList(inputReads)
            
            if p.show():
                
                channelNames = []
                temp=0
                for cn in inputReads:
                    channelNames.append(p.value(inputReads[temp]))
                    temp+=1
                
                #check if all channels have a name
                isEmpty=0
                allUnder30Char = 0
                for c in channelNames:
                    if c == "":
                        isEmpty+=1
                    if len(c)>30:
                        allUnder30Char += 1 
                
                if isEmpty>0:
                    nuke.message("you haven't named all channels.")
                    MultiChannelCombine()
                    
                else:
                    
                    if allUnder30Char==0:
                        for img in images:
            
                            #autoplace selected nodes
                            nuke.autoplace(img)
                            
                            #get all the filenames to use them as pass name
                            imagePath = img.knob("file").value()  
                            imageSplit=imagePath.split("/")
                            lastVal = imageSplit.pop()     
                            #cutouts
                            lastVal = lastVal.split(".")    
                            passName = lastVal[0]  
                            #frame padding %
                            lastVal = passName.split("%")    
                            passName = lastVal[0]       
                            passes.append(passName)
                            
                            print "passes %s" % passes
                            
                            if i>0:
                                if i==1:
                                    #initialize pipe2 for first round 
                                    pipe2=images[0]
                               
                                print pipe2
                               
                                #creating shuffle
                                shuffle = nuke.nodes.ShuffleCopy()
                                
                                
                                
                                shuffle.setName("shuffle_%s" % channelNames[i])
                                shuffle.setInput(0, pipe2)
                                shuffle.setInput(1, images[i])
                                
                                #creating channels
                                r_temp=channelNames[i]+".red"
                                g_temp=channelNames[i]+".green"
                                b_temp=channelNames[i]+".blue"
                                newLayer = nuke.Layer(channelNames[i],[r_temp, g_temp, b_temp])        
                                
                                #setting up the shuffle nodes inputs and outputs
                                shuffle.knob("out2").setValue(channelNames[i])  
                                
                                shuffle['red'].setValue('red2')
                                shuffle['green'].setValue('green2')
                                shuffle['blue'].setValue('blue2') 
                                shuffle['alpha'].setValue('alpha2') 
                        
                                shuffle['black'].setValue('red') 
                                shuffle['white'].setValue('green')
                                shuffle['red2'].setValue('blue') 
                                shuffle['green2'].setValue('alpha') 
                                
                                
                                    #this was a reported bug; 
                                    #it's right that red2 is actually called black, green2 is actually called white, blue2 is actually called red2 and alpha2 is actually called green2
                                    #pretty strange but it is like that
                                    #look here:
                                    #http://forums.thefoundry.co.uk/phpBB2/viewtopic.php?t=5954&sid=5eba0be48c454bf34bc7bdf301983a21  
                                
                                #safe last shuffle for next round to pipe it in in shuffleknob pipe2
                                pipe2 = shuffle;
                         
                            i+=1
                        
                        #create metadata-tag when comment was set
                        lastShuffle = nuke.toNode("shuffle_"+channelNames[len(channelNames)-1])
                        commentVal=""
                        commentVal = p.value("comment (optional): ")
                        if commentVal!="":
                            md=nuke.nodes.ModifyMetaData()
                            md.knob("metadata").fromScript("{set comment %s}" % commentVal.replace(" ","_") )
                            md.setName("comment")
                            md.setInput(0,lastShuffle)
                        
                        #create write node
                        write = nuke.nodes.Write()
                        write.knob("file_type").setValue("exr")
                        write.knob("compression").setValue("Zip (16 scanlines)")
                        write.knob("channels").setValue("all")
                        if commentVal!="":
                            write.setInput(0,md)
                            write.knob("metadata").setValue("all metadata")
                        else:
                            write.setInput(0,lastShuffle)
                
                    else:
                        nuke.message("Wait, the channel names are too long. Pleae make sure, that each channel name is under 30 characters long. Otherwise the exr does not work properly.")
            
        else:
            nuke.message("Please make sure to select READ nodes only")
    else:
        nuke.message("Please select at least 2 Read Nodes")
예제 #12
0
def autocrop(first=None, last=None, inc=None, layer="rgba"):
    """Run the CurveTool's AutoCrop function on each selected node over the
  specified frame range and channels. If the range values are None, the
  project first_frame and last_frame are used; if inc is None, 1 is used.
  After execution, the CurveTool AutoCrop results are copied into a Crop
  node attached to each selected node."""

    # Sort out execute range
    root = nuke.root()
    if first is None:
        first = int(root.knob("first_frame").value())
    if last is None:
        last = int(root.knob("last_frame").value())
    if inc is None:
        inc = 1

    # Remember original set of selected nodes...we'll need this
    original_nodes = nuke.selectedNodes()

    # Deselect everything so we can add CurveTool nodes
    all_nodes = nuke.allNodes()
    for i in all_nodes:
        i.knob("selected").setValue(False)

    for i in original_nodes:
        # Reselect originally selected nodes and create a CurveTool node,
        # which will automatically connect to the last selected.
        i.knob("selected").setValue(True)
        autocropper = nuke.createNode(
            "CurveTool",
            '''operation 0 ROI {0 0 input.width input.height} Layer %s label "Processing Crop..." selected true'''
            % (str(layer), ), False)

        # Execute the CurveTool node thru all the frames
        nuke.executeMultiple([
            autocropper,
        ], ([first, last, inc], ))

        # select the curvewriter
        autocropper.knob("selected").setValue(True)

        # add crop node
        cropnode = nuke.createNode("Crop", "label AutoCrop", False)

        # put the new data from the autocrop into the new crop
        cropbox = cropnode.knob("box")
        autocropbox = autocropper.knob("autocropdata")
        cropbox.copyAnimations(autocropbox.animations())

        # turn on the animated flag
        cropnode.knob("indicators").setValue(1)

        # deselect everything
        all_nodes = nuke.allNodes()
        for j in all_nodes:
            j.knob("selected").setValue(False)

        # select the curvewriter and delete it
        autocropper.knob("selected").setValue(True)

        # delete the autocropper to make it all clean
        nodes.node_delete()

        # deselect everything
        all_nodes = nuke.allNodes()
        for j in all_nodes:
            j.knob("selected").setValue(False)

        # select the new crop
        cropnode.knob("selected").setValue(True)

        # place it in a nice spot
        nuke.autoplace(cropnode)

        # De-Select it
        cropnode.knob("selected").setValue(False)
예제 #13
0
파일: app.py 프로젝트: moChen0607/codeLab
    def create_assets(self):
        # plan_dir = self.assets_dir + r'/S03_P17'
        # plans = os.listdir(self.assets_dir)
        plan_items = self.plan_lst.selectedItems()
        for plan in plan_items:
            _frames = 0
            layers = ""
            names = ""
            persons = ""
            aovs = ""
            # print plan
            plan_dir = self.assets_dir + r'/' + plan.text()
            layers = os.listdir(plan_dir)

            for layer in layers:
                read_nodes_list = []
                bd_color = 0xffffff11
                new_nodes = []
                backdrop_nodes = []
                # print "\t" + layer
                name_dir = plan_dir + r'/' + layer
                names = os.listdir(name_dir)

                if layer == 'Characters' or layer == 'Environment' or layer == 'Props':
                    if layer == 'Characters':
                        for name in names:
                            # print "\t\t" + name
                            persons_dir = name_dir + r'/' + name
                            persons = os.listdir(persons_dir)

                            for person in persons:
                                # print "\t\t\t" + person
                                aovs_dir = persons_dir + r'/' + person
                                aovs = os.listdir(aovs_dir)
                                if _frames == 0:
                                    _frames = len(aovs)

                                # import files as read file
                                file_path = aovs_dir + r'/' + \
                                    aovs[0].replace('0000', '####')
                                readed_file = nuke.createNode('Read')
                                readed_file.knob('file').setValue(file_path)
                                readed_file.knob('origfirst').setValue(0)
                                readed_file.knob('origlast').setValue(_frames -
                                                                      1)
                                readed_file.knob('first').setValue(0)
                                readed_file.knob('last').setValue(_frames - 1)
                                readed_file.knob('format').setValue('HD_720')
                                file_name = layer + '_' + name + '_' + person
                                readed_file.knob('name').setValue(file_name)
                                read_nodes_list.append(
                                    readed_file.knob('name').getValue())
                                bd_color = colors.colors_dict[name.lower()]
                    else:
                        for name in names:
                            # print "\t\t" + name
                            aovs_dir = name_dir + r'/' + name
                            aovs = os.listdir(aovs_dir)

                            if _frames == 0:
                                _frames = len(aovs)

                            # import files as read file
                            file_path = aovs_dir + r'/' + \
                                aovs[0].replace('0000', '####')
                            readed_file = nuke.createNode('Read')
                            readed_file.knob('file').setValue(file_path)
                            readed_file.knob('origfirst').setValue(0)
                            readed_file.knob('origlast').setValue(_frames - 1)
                            readed_file.knob('first').setValue(0)
                            readed_file.knob('last').setValue(_frames - 1)
                            readed_file.knob('format').setValue('HD_720')
                            file_name = layer + '_' + name
                            readed_file.knob('name').setValue(file_name)
                            read_nodes_list.append(
                                readed_file.knob('name').getValue())
                            bd_color = colors.colors_dict[layer.lower()]
                else:
                    aovs = os.listdir(name_dir)

                    if _frames == 0:
                        _frames = len(aovs)

                    # import files as read file
                    file_path = name_dir + r'/' + \
                        aovs[0].replace('0000', '####')
                    readed_file = nuke.createNode('Read')
                    readed_file.knob('file').setValue(file_path)
                    readed_file.knob('origfirst').setValue(0)
                    readed_file.knob('origlast').setValue(_frames - 1)
                    readed_file.knob('first').setValue(0)
                    readed_file.knob('last').setValue(_frames - 1)
                    readed_file.knob('format').setValue('HD_720')
                    file_name = layer
                    readed_file.knob('name').setValue(file_name)
                    read_nodes_list.append(readed_file.knob('name').getValue())
                    bd_color = colors.colors_dict[layer.lower()]

                # create merge nodes and connect them
                for node in read_nodes_list:
                    backdrop_nodes.append(node)
                    if node.find('beauty') != -1:
                        continue
                    else:
                        new_nodes.append(node)

                if len(new_nodes) > 1:
                    for i in range(1, len(new_nodes)):
                        m = nuke.createNode('Merge2')
                        m.knob('name').setValue('MERGE_' + layer + '_' +
                                                str(i))
                        m.knob('operation').setValue('plus')
                        backdrop_nodes.append(m.knob('name').getValue())

                    for i in range(len(new_nodes)):
                        if i == 0:
                            n1 = nuke.toNode(new_nodes[i])
                            n2 = nuke.toNode(new_nodes[i + 1])
                            m = nuke.toNode('MERGE_' + layer + '_' +
                                            str(i + 1))
                            m.setInput(0, n1)
                            m.setInput(1, n2)
                        elif i >= 2:
                            n = nuke.toNode(new_nodes[i])
                            m = nuke.toNode('MERGE_' + layer + '_' + str(i))
                            m.setInput(0, n)

                # print '-' * 30
                # n = nuke.toNode("Props_direct_specular")
                # n.knob('selected').setValue(True)
                # nuke.selectConnectedNodes()
                # print backdrop_nodes
                for bn in backdrop_nodes:
                    n = nuke.toNode(bn)
                    n.knob('selected').setValue(True)
                    nuke.autoplace(n)
                bd = nukescripts.autoBackdrop()
                bd.knob('name').setValue('BD_' + layer)
                bd.knob('label').setValue('layer: ' + layer)
                bd.knob('note_font_size').setValue(13)
                # 0xRRGGBB00
                bd.knob('tile_color').setValue(bd_color)

            self.plan_lst.removeItemWidget(plan)
        '''
예제 #14
0
def autoplace_all():
    for n in nuke.allNodes():
        nuke.autoplace(n)
예제 #15
0
def autoCrop_MB():
    #Check if a node is selected.
    try:
        n = nuke.selectedNode()
        nodeClass = n.Class()
    except:
        n = 0

    #Run if statement based on above try statement.
    if n == 0:
        print nuke.message('Please selected a node to run autoCrop_MB on...')
    else:
        #Check how many nodes are selected.
        numberOfNodes = len(nuke.selectedNodes())

        #Convert the int to a str.
        numberOfNodesInt = str(numberOfNodes)

    #Get channels from stream and sort so alpha is at the top.
    channelL = n.channels()
    channelS = channelL.sort()

    #Convert list to a string and add space.
    channelS = ' '.join(channelL)

    if nodeClass == 'Read':
        range = 'input' + ' ' + 'global' + ' ' + 'custom'
    else:
        range = 'global' + ' ' + 'custom'

    #Create and execute panel.
    p = nuke.Panel('autoCrop_MB v3.5')
    p.addEnumerationPulldown('frame range', range)
    p.addSingleLineInput('custom start', '')
    p.addSingleLineInput('custom end', '')
    p.addEnumerationPulldown('layer', channelS)
    p.addBooleanCheckBox('crop to format', False)
    p.show()

    increment = int('1')
    layersForCrop = p.value('layer')
    #Add quotation marks to layers variables.
    layersToAnalysis = '\"' + layersForCrop + '\"'

    #Work out the frame range wanted.
    if p.value('frame range') == 'custom':
        startFrame = int(p.value('custom start'))
        endFrame = int(p.value('custom end'))
    else:
        if p.value('frame range') == 'input':
            startFrame = n.knob('first').getValue()
            endFrame = n.knob('last').getValue()
        else:
            root = nuke.root()
            startFrame = int(root.knob("first_frame").value())
            endFrame = int(root.knob("last_frame").value())

#Reset variables.

    first = startFrame
    last = endFrame
    inc = increment
    layer = layersToAnalysis

    #Run autocrop in curve tool.  Taken from The Foundry's nukescripts/crop.py

    # Remember original set of selected nodes...we'll need this
    original_nodes = nuke.selectedNodes()

    # Deselect everything so we can add CurveTool nodes
    all_nodes = nuke.allNodes()
    for i in all_nodes:
        i.knob("selected").setValue(False)

    for i in original_nodes:
        # Reselect originally selected nodes and create a CurveTool node,
        # which will automatically connect to the last selected.
        i.knob("selected").setValue(True)
        #Check if user wants to analysis outside the format.
        if p.value('crop to format') == True:
            autocropper = nuke.createNode(
                "CurveTool",
                '''operation 0 ROI {0 0 input.width input.height} Layer %s label "Processing Crop..." selected true'''
                % (str(layer), ), False)
        else:
            autocropper = nuke.createNode(
                "CurveTool",
                '''operation 0 ROI {input.bbox.x input.bbox.y input.bbox.r input.bbox.t} Layer %s label "Processing Crop..." selected true'''
                % (str(layer), ), False)

    # Execute the CurveTool node thru all the frames
    nuke.executeMultiple([
        autocropper,
    ], ([first, last, inc], ))

    # select the curvewriter
    autocropper.knob("selected").setValue(True)

    # add crop node
    cropnode = nuke.createNode("Crop", "label AutoCrop", False)

    # put the new data from the autocrop into the new crop
    cropbox = cropnode.knob("box")
    autocropbox = autocropper.knob("autocropdata")
    cropbox.copyAnimations(autocropbox.animations())

    # turn on the animated flag
    cropnode.knob("indicators").setValue(1)

    # deselect everything
    all_nodes = nuke.allNodes()
    for j in all_nodes:
        j.knob("selected").setValue(False)

    # select the curvewriter and delete it
    autocropper.knob("selected").setValue(True)

    # delete the autocropper to make it all clean
    #nodes.node_delete()
    nuke.delete(autocropper)

    # deselect everything
    all_nodes = nuke.allNodes()
    for j in all_nodes:
        j.knob("selected").setValue(False)

    # select the new crop
    cropnode.knob("selected").setValue(True)

    # place it in a nice spot
    nuke.autoplace(cropnode)

    # De-Select it
    cropnode.knob("selected").setValue(False)
예제 #16
0
def loadSelectedcomments():
    """Loads the comments for a selected node from the server. Comments are generated as text nodes inside a group"""
    nodes = nuke.selectedNodes()
    nukeroot = nuke.root()
    previouscommand = "animCurve = nuke.thisNode()['comment'].animation( 0 ) \nframe = False\nfor i in xrange(len(animCurve.keys())):\n    if nuke.frame() > animCurve.keys()[i].x:\n        frame = animCurve.keys()[i].x     \nif frame:\n    nuke.frame(frame)"
    nextcommand = "animCurve = nuke.thisNode()['comment'].animation( 0 ) \nframe = False\nfor i in xrange(len(animCurve.keys())):\n    if nuke.frame() < animCurve.keys()[i].x:\n        frame = animCurve.keys()[i].x\n        break\nif frame:\n    nuke.frame(frame)"
    if not 'frameioproject' in nukeroot.knobs():
        return False
    if nukeroot['frameioproject'].value() == '0':
        project = ''
    else:
        project = nukeroot['frameioproject'].value()
    for node in nodes:
        if not 'file' in node.knobs():
            continue
        filepath = os.path.abspath(node['file'].value())
        if not os.path.isfile(filepath):
            continue
        frameiosession = login(nukeroot['frameiousername'].value(), project)
        if frameiosession == None:
            return False
        projectid = node['projectid'].value()
        filereferenceid = node['filereferenceid'].value()
        frameiosession.setProjectid(projectid)
        filereference = frameiosession.getFilereference(filereferenceid)
        commentdict = filereference.getComments()
        if not commentdict:
            return False

        group = nuke.createNode('Group')

        group.addKnob(nuke.Tab_Knob('frameio', 'frame.io'))
        group.addKnob(nuke.Int_Knob('comment', 'Comment'))
        group.addKnob(nuke.Int_Knob('of', 'of'))
        group.addKnob(
            nuke.PyScript_Knob('previous', 'previous', previouscommand))
        group.addKnob(nuke.PyScript_Knob('next', 'next', nextcommand))
        group.addKnob(nuke.Boolean_Knob('showtext', 'Show text', True))
        group.addKnob(
            nuke.Boolean_Knob('showannotation', 'Show annotation', True))
        group.addKnob(nuke.Double_Knob('global_font_scale', 'Font scale'))
        group['global_font_scale'].setValue(.25)
        group['of'].clearFlag(nuke.STARTLINE)
        group['showtext'].setFlag(nuke.STARTLINE)
        group['comment'].setAnimated()
        i = 1
        while nuke.toNode('Comments' + str(i)) != None:
            i += 1
        group['name'].setValue('Comments' + str(i))
        group['label'].setValue(os.path.basename(filepath))
        with group:
            input = nuke.createNode('Input')
            input.hideControlPanel()
            i = 0
            for timestamps in sorted(commentdict.keys()):
                for comment in commentdict[timestamps]:
                    if node.Class() == 'Read':
                        if node['frame'].value() == '':
                            offset = 0
                        else:
                            offset = int(node['frame'].value())
                    else:
                        offset = int(nuke.root()['first_frame'].value())
                    frame = round(timestamps) + offset
                    user = comment[0]
                    text = comment[1]
                    draw_data = comment[2]
                    group['comment'].setValueAt(i + 1, frame)
                    textnode = nuke.createNode('Text2')
                    textnode['box'].setValue(
                        [10, 10, node.width() / 2,
                         node.height()])
                    textnode['yjustify'].setValue('bottom')
                    textnode['global_font_scale'].setExpression(
                        'parent.global_font_scale')
                    textnode['enable_background'].setValue(True)
                    textnode['background_opacity'].setValue(0.9)
                    textnode['useLifetime'].setValue(True)
                    textnode['lifetimeStart'].setValue(frame)
                    textnode['lifetimeEnd'].setValue(frame)
                    textnode['disable'].setExpression('1-parent.showtext')
                    annotationNode(draw_data, node.width(), node.height(),
                                   frame)
                    message = user
                    message += '\n\n'
                    message += text
                    textnode['message'].setValue(message.encode('utf-8'))
                    textnode.hideControlPanel()
                    i += 1
            group['of'].setValue(i)
            output = nuke.createNode('Output')
            output.hideControlPanel()
        group.setInput(0, node)
        nuke.autoplace(group)
예제 #17
0
def loadSelectedcomments():
    """Loads the comments for a selected node from the server. Comments are generated as text nodes inside a group"""
    nodes = nuke.selectedNodes()
    nukeroot = nuke.root()
    previouscommand = "animCurve = nuke.thisNode()['comment'].animation( 0 ) \nframe = False\nfor i in xrange(len(animCurve.keys())):\n    if nuke.frame() > animCurve.keys()[i].x:\n        frame = animCurve.keys()[i].x     \nif frame:\n    nuke.frame(frame)"
    nextcommand = "animCurve = nuke.thisNode()['comment'].animation( 0 ) \nframe = False\nfor i in xrange(len(animCurve.keys())):\n    if nuke.frame() < animCurve.keys()[i].x:\n        frame = animCurve.keys()[i].x\n        break\nif frame:\n    nuke.frame(frame)"
    if not 'frameioproject' in nukeroot.knobs():
        return False
    if nukeroot['frameioproject'].value() == '0':
        project = ''
    else:
        project = nukeroot['frameioproject'].value()
    for node in nodes:
        if not 'file' in node.knobs():
            continue
        filepath = os.path.abspath(node['file'].value())
        if not os.path.isfile(filepath):
            continue
        frameiosession = login( nukeroot['frameiousername'].value() , project )
        if frameiosession == None:
            return False
        projectid = node['projectid'].value()
        filereferenceid = node['filereferenceid'].value()
        frameiosession.setProjectid(projectid)
        filereference = frameiosession.getFilereference(filereferenceid)
        commentdict = filereference.getComments()
        if not commentdict:
            return False
        
        group = nuke.createNode('Group')
        
        group.addKnob( nuke.Tab_Knob('frameio' , 'frame.io') )
        group.addKnob( nuke.Int_Knob('comment' , 'Comment') )
        group.addKnob( nuke.Int_Knob('of' , 'of') )
        group.addKnob( nuke.PyScript_Knob('previous' , 'previous' , previouscommand ) )
        group.addKnob( nuke.PyScript_Knob('next' , 'next' , nextcommand ) )
        group.addKnob( nuke.Boolean_Knob('showtext' , 'Show text' , True ) )
        group.addKnob( nuke.Boolean_Knob('showannotation' , 'Show annotation' , True ) )
        group.addKnob( nuke.Double_Knob('global_font_scale' , 'Font scale' ) )
        group['global_font_scale'].setValue(.25)
        group['of'].clearFlag(nuke.STARTLINE)
        group['showtext'].setFlag(nuke.STARTLINE)
        group['comment'].setAnimated()
        i = 1
        while nuke.toNode('Comments' + str(i)) != None:
            i+=1
        group['name'].setValue('Comments' + str(i))
        group['label'].setValue(os.path.basename(filepath))
        with group:
            input = nuke.createNode('Input')
            input.hideControlPanel() 
            i = 0
            for timestamps in sorted(commentdict.keys()):
                for comment in commentdict[timestamps]:
                    if node.Class() == 'Read':
                        if node['frame'].value() == '':
                            offset = 0
                        else:
                            offset = int(node['frame'].value())
                    else:
                        offset = int(nuke.root()['first_frame'].value())
                    frame = round(timestamps) + offset
                    user = comment[0]
                    text = comment[1]
                    draw_data = comment[2]
                    group['comment'].setValueAt( i+1, frame )
                    textnode = nuke.createNode('Text2')
                    textnode['box'].setValue([10,10,node.width()/2,node.height()] )
                    textnode['yjustify'].setValue('bottom')
                    textnode['global_font_scale'].setExpression( 'parent.global_font_scale' )
                    textnode['enable_background'].setValue(True)
                    textnode['background_opacity'].setValue(0.9)
                    textnode['useLifetime'].setValue(True)
                    textnode['lifetimeStart'].setValue( frame )
                    textnode['lifetimeEnd'].setValue( frame )
                    textnode['disable'].setExpression( '1-parent.showtext' )
                    annotationNode(draw_data , node.width(), node.height(), frame)
                    message = user
                    message += '\n\n'
                    message += text
                    textnode['message'].setValue(message.encode('utf-8'))
                    textnode.hideControlPanel() 
                    i+=1
            group['of'].setValue(i)
            output = nuke.createNode('Output')
            output.hideControlPanel() 
        group.setInput(0, node)
        nuke.autoplace(group)