Пример #1
0
def bakeProjection(mb):
    """Create a projection setup for the current frame."""
    if mb.Class() != "ModelBuilder":
        return

    clearNodeSelection()
    srcCam = mb.input(1)
    if not srcCam:
        return
    w = mb.screenWidth()
    h = mb.screenHeight()
    src = mb.input(0)
    frame = nuke.frame()
    if (mb['textureType'].getValue() > 0):
        frame = mb['textureFrame'].getValue()
    label = '(frame ' + str(frame) + ')'

    srcdot = nuke.createNode('Dot', '', False)
    srcdot.setInput(0, src)
    srchold = nuke.createNode('FrameHold', '', False)
    stamp = nuke.createNode('PostageStamp', '', False)
    project = nuke.createNode('Project3D', '', False)
    apply = nuke.createNode('ApplyMaterial', '', False)

    cam = copyCamera(srcCam)

    camhold = nuke.clone(srchold, '', False)
    camdot = nuke.createNode('Dot', '', False)
    project.setInput(1, camdot)

    srcdot.setXYpos(int(mb.xpos() + w * 3.5), int(mb.ypos()))
    srchold.setXYpos(int(srchold.xpos()), int(srcdot.ypos() + w))
    stamp.setXYpos(int(stamp.xpos()),
                   int(stamp.ypos() + srchold.screenHeight() + h * 2))
    cam.setXYpos(
        int(srchold.xpos() - w * 1.5),
        int(srchold.ypos() + srchold.screenHeight() / 2 -
            cam.screenHeight() / 2))
    camhold.setXYpos(
        int(cam.xpos() + cam.screenWidth() / 2 - srchold.screenWidth() / 2),
        int(stamp.ypos() + h))
    project.setXYpos(int(stamp.xpos()),
                     int(stamp.ypos() + stamp.screenHeight() + h * 2))
    camdot.setXYpos(
        int(camdot.xpos()),
        int(project.ypos() + project.screenHeight() / 2 -
            camdot.screenHeight() / 2))
    apply.setXYpos(int(stamp.xpos()), int(apply.ypos() + w))

    srchold.knob('first_frame').setValue(frame)
    srcdot.setSelected(True)
    srchold.setSelected(True)
    stamp.setSelected(True)
    project.setSelected(True)
    apply.setSelected(True)
    cam.setSelected(True)
    camhold.setSelected(True)
    camdot.setSelected(True)
    bd = nukescripts.autoBackdrop()
    bd['label'].setValue('Frame %d' % frame)
    def attach_nodes(self):
        """This function takes the data from the panel and attaches
        created nodes to selected nodes, with the option to clone."""

        # Define variables:
        attached_node = self.attached_node.text()
        clone_node = self.clone_node.isChecked()

        # Attach node(s):
        for node in self.selected:
            node.setSelected(False)

        try:
            if clone_node is False:
                for node in self.selected:
                    node.setSelected(True)
                    created_node = nuke.createNode(attached_node.title())
                    self.created_nodes.append(created_node)  # add to list
                    node.setSelected(False)
                    created_node.setSelected(False)

            # Clone node:
            if clone_node is True:
                if self.selected[0]:
                    self.selected[0].setSelected(True)
                    created_node = nuke.createNode(attached_node.title())
                    self.created_nodes.append(created_node)  # add to list
                    created_node.setSelected(False)

                del self.selected[0]

                for node in self.selected:
                    node.setSelected(True)
                    nuke.clone(created_node)
                    node.setSelected(False)
                    created_node.setSelected(False)

            self.created_nodes[0].setSelected(True)

        except RuntimeError:
            nuke.message('The name you entered was not a node name.'
                         ' Please enter a node name.')

        # Show Panel 2 if Panel 1 is successful:
        if self.created_nodes:
            self.panel_two = ANSetKnobs()
            self.panel_two.show()
Пример #3
0
def copyCamera(srcCam):
    while srcCam is not None and srcCam.Class() == 'Dot':
        srcCam = srcCam.input(0)
    if srcCam.Class() == 'Camera':
        newCam = nuke.createNode('Camera')
        newCam.readKnobs(srcCam.writeKnobs(nuke.TO_SCRIPT))
    else:
        clearNodeSelection()
        newCam = nuke.clone(srcCam, '', False)
        newCam.setSelected(True)
    return newCam
Пример #4
0
def autoBackdrop():
    name = nuke.getInput("Label?")
    selNodes = nuke.selectedNodes()
    if not selNodes:
        return nuke.nodes.BackdropNode(label=name)

    n = nukescripts.autoBackdrop()
    n.knob("label").setValue(name)
    xmin = n["xpos"].value()
    xmax = xmin + n["bdwidth"].value()
    ymin = n["ypos"].value()
    ymax = ymin + n["bdheight"].value()

    for node in nuke.selectedNodes():
        x, y = node["xpos"].value(), node["ypos"].value()
        if x > xmin and x < xmax and y > ymin and y < ymax and node.Class(
        ) == "BackdropNode":
            new = nuke.clone(node)
            nuke.delete(node)
            new["xpos"].setValue(x)
            new["ypos"].setValue(y)
Пример #5
0
    def FKBSMergCam(self, mode):
        self.mode = mode
        #选择所有的节点
        _source = nuke.selectedNodes('Read')
        self.numSelect = len(_source)
        #定义_contactSheet方格 _constant黑板 _backDropStr背板、保存的摄像机字典
        _contactSheet, _constant, _backDropStr, _contactSheet1, _constant1, _backDropStr1 = '', '', '', '', '', ''
        _sortedCam = {}
        #搜索所选的内容
        if len(nuke.selectedNodes('ContactSheet')):
            nuke.message('ContactSheet Nodes Not Can Selected...')
            return
        if len(nuke.selectedNodes('Constant')):
            nuke.message('ContactSheet Nodes Not Can Selected...')
            return
        if len(_source) == 0:
            nuke.message('No Read Nodes Selected...')
            return

        #以所选的第一个素材为例,定义素材的格式_w _h
        _node = _source[0]
        #获取第一个素材在nuke中的位置
        _w = _node.knob('format').value().width()
        _h = _node.knob('format').value().height()

        #获取第一个素材的大小
        _bbox = [_node.screenWidth(), _node.screenHeight()]
        _pos = [_node.xpos(), _node.ypos()]

        #常见点节点,并设置它的坐标为第一个素材的节点位置
        _dot = nuke.nodes.Dot()
        _dot.setXYpos(_pos[0], _pos[1])

        _pattern = ((-6, 0), (-5, 0), (-4, 0), (-3, 0), (-2, 0), (-1, 0),
                    (1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0))

        _contactSheet = nuke.nodes.ContactSheet(width=_w * self.numSelect / 2,
                                                height=_h,
                                                rows=1,
                                                columns=self.numSelect / 2,
                                                roworder='TopBottom').name()

        _contactSheet1 = nuke.nodes.ContactSheet(width=_w * self.numSelect / 2,
                                                 height=_h,
                                                 rows=1,
                                                 columns=self.numSelect / 2,
                                                 roworder='TopBottom').name()

        #在所有的尺寸格式中,寻找跟素材一样样式,在创建黑板,并设置位置
        if _constant == "":
            _allFormat = nuke.formats()
            for _eachFormat in _allFormat:
                if _eachFormat.width() == _w and _eachFormat.height() == _h:
                    _constant = nuke.nodes.Constant(
                        format=_eachFormat.name()).name()
                    _constant1 = nuke.nodes.Constant(
                        format=_eachFormat.name()).name()
                    _node = nuke.toNode(_constant)
                    _node1 = nuke.toNode(_constant1)
                    break

        #在每个素材中记录摄像机,并记录黑板的名字
        for each in _source:
            camStr = self.checkFile(each)
            if camStr:
                _sortedCam[camStr[0]] = each
                if not _backDropStr:
                    _backDropStr = camStr[1]
                else:
                    each.setSelected(False)
        _sheeNode = nuke.toNode(_contactSheet)
        _sheeNode1 = nuke.toNode(_contactSheet1)
        _conNode = nuke.toNode(_constant)
        _conNode1 = nuke.toNode(_constant1)

        for _x in range(18):
            _sheeNode.setInput(_x, _conNode)
            _sheeNode1.setInput(_x, _conNode1)

        #判断素材的格式
        myfileFlagEXR = False
        #查询第一个素材的路径
        myfileName = _source[0]['file'].value()
        #获取素材的格式
        myfileNameType = os.path.splitext(myfileName)[1]
        if myfileNameType:
            if myfileNameType.find('exr') >= 0:
                myfileFlagEXR = True

        MergCamL = []
        MergCamR = []

        myii = 0
        myii1 = 0
        for _k, _v in _sortedCam.iteritems():
            #print _k
            #print _v
            _sourceNode = _v
            myKey = _k
            if self.mode == 1:
                if self.num[myKey] < 7:
                    _sheeNode.setInput(self.num[myKey] - 1, _sourceNode)
                    _pick = _pattern[self.num[myKey] - 1]
                    #设置素材的在nuke中的位置
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())
                    MergCamL.append(_sourceNode)
                else:
                    _sheeNode1.setInput(self.num[myKey] - 7, _sourceNode)
                    _pick1 = _pattern[self.num[myKey] - 1]
                    #设置素材的在nuke的位置
                    _sourceNode.setXYpos(_bbox[0] * _pick1[0] + _dot.xpos(),
                                         _bbox[1] * _pick1[1] + _dot.ypos())
                    MergCamR.append(_sourceNode)

            elif self.mode == 2:
                if not myfileFlagEXR:
                    if self.num[myKey] < 7:
                        _sheeNode.setInput(self.num[myKey] - 1, _sourceNode)
                        _pick = _pattern[self.num[myKey] - 1]
                        #设置素材的在nuke中的位置
                        _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                             _bbox[1] * _pick[1] + _dot.ypos())
                        MergCamL.append(_sourceNode)
                    else:
                        _sheeNode1.setInput(self.num[myKey] - 7, _sourceNode)
                        _pick1 = _pattern[self.num[myKey] - 1]
                        #设置素材的在nuke的位置
                        _sourceNode.setXYpos(
                            _bbox[0] * _pick1[0] + _dot.xpos(),
                            _bbox[1] * _pick1[1] + _dot.ypos())
                        MergCamR.append(_sourceNode)

                else:
                    if self.num[myKey] < 7:
                        if myii == 0:
                            myShuffle = nuke.nodes.Shuffle()
                            myShuffle.setInput(0, _sourceNode)
                            _pick = _pattern[self.num[myKey] - 1]
                            _sheeNode.setInput(self.num[myKey] - 1, myShuffle)
                            _sourceNode.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                            myShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                        else:
                            self.setSelecteNone()
                            newMyShuffle = nuke.clone(myShuffle)
                            newMyShuffle.setInput(0, _sourceNode)
                            _pick = _pattern[self.num[myKey] - 1]
                            _sheeNode.setInput(self.num[myKey] - 1,
                                               newMyShuffle)
                            _sourceNode.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                            newMyShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                        MergCamL.append(_sourceNode)
                        myii = myii + 1

                    else:
                        if myii1 == 0:
                            myShuffle1 = nuke.nodes.Shuffle()
                            myShuffle1.setInput(0, _sourceNode)
                            _pick1 = _pattern[self.num[myKey] - 1]
                            _sheeNode1.setInput(self.num[myKey] - 7,
                                                myShuffle1)

                            _sourceNode.setXYpos(
                                _bbox[0] * _pick1[0] + _dot.xpos(),
                                _bbox[1] * _pick1[1] + _dot.ypos())
                            myShuffle1.setXYpos(
                                _bbox[0] * _pick1[0] + _dot.xpos(),
                                _bbox[1] * _pick1[1] + _dot.ypos())
                        else:
                            self.setSelecteNone()
                            newMyShuffle1 = nuke.clone(myShuffle1)
                            newMyShuffle1.setInput(0, _sourceNode)
                            _pick1 = _pattern[self.num[myKey] - 1]
                            _sheeNode1.setInput(self.num[myKey] - 7,
                                                newMyShuffle1)

                            _sourceNode.setXYpos(
                                _bbox[0] * _pick1[0] + _dot.xpos(),
                                _bbox[1] * _pick1[1] + _dot.ypos())
                            newMyShuffle1.setXYpos(
                                _bbox[0] * _pick1[0] + _dot.xpos(),
                                _bbox[1] * _pick1[1] + _dot.ypos())
                        MergCamR.append(_sourceNode)
                        myii1 = myii1 + 1

        self.setSelecteNone()

        for each in MergCamL:
            each.setSelected(1)

        _sheeNode.setXYpos(_dot.xpos() - _bbox[0] * 3 - _bbox[0] / 2,
                           _dot.ypos() + _bbox[1] * 2 - 30)

        _conNode.setXYpos(_dot.xpos() - _bbox[0] * 2,
                          _dot.ypos() + _bbox[1] * 1 - 10)

        #删除黑板
        conUsed = _conNode.dependent()

        if not conUsed:
            nuke.delete(_conNode)
        else:
            _conNode.setSelected(1)
        _sheeNode.setSelected(1)

        bd = nukescripts.autoBackdrop()
        bd.knob('label').setValue(_backDropStr)
        myOldbdHeight = bd.knob('bdheight').value()
        bd.knob('bdheight').setValue(myOldbdHeight + 15)

        self.setSelecteNone()
        for each in MergCamR:
            each.setSelected(1)

        _sheeNode1.setXYpos(_dot.xpos() + _bbox[0] * 3 + _bbox[0] / 2,
                            _dot.ypos() + _bbox[1] * 2 - 30)

        _conNode1.setXYpos(_dot.xpos() + _bbox[0] * 5,
                           _dot.ypos() + _bbox[1] * 1 - 10)
        _conNode1.setSelected(1)
        _sheeNode1.setSelected(1)
        nuke.delete(_dot)
        bd1 = nukescripts.autoBackdrop()
        bd1.knob('label').setValue(_backDropStr)
        myOldbdHeight = bd1.knob('bdheight').value()
        bd1.knob('bdheight').setValue(myOldbdHeight + 15)
Пример #6
0
    def mergeCamera(self,layer,_source,_bd_X,backDropStr):
        #获取选择的Read节点的个数
        self.numSelect=len(_source)
        #所选择的_contactSheet方格 _constant黑板 _backDropStr背板
        _contactSheet,_constant,_bd='','',''
        #新创建的_contactSheet方格 _constant黑板 _backDropStr背板
        _contactSheet_1,_constant_1,_backDropStr='','',''
        #保存的摄像机字典
        _sortedCam = {}
        _backDropStr=backDropStr.knob('label').value()
        #获取所选择的contactSheet方格 _constant黑板 _backDropStr背板中的信息
        if len(nuke.selectedNodes('ContactSheet')):
            _contactSheet=nuke.selectedNodes('ContactSheet')[0]
            _contactSheet.setSelected(False)
            #获取所选择的ContactSheet的信息
            conts_w=_contactSheet.knob('rows').value()
            conts_h=_contactSheet.knob('columns').value()
            conts_row=_contactSheet.knob('roworder').value()
            conts_width=_contactSheet.knob('width').value()
            conts_height=_contactSheet.knob('height').value()
            const_color=_contactSheet.knob('colorder').value()
            const_split=_contactSheet.knob('splitinputs').value()

        if len(nuke.selectedNodes('Constant')):
            _constant=nuke.selectedNodes('Constant')[0]
            _constant.setSelected(False)

        if len(nuke.selectedNodes('BackdropNode')):
            _bd=nuke.selectedNodes('BackdropNode')[0]
            _bd.setSelected(False)
        else:
            nuke.message('No BackdropNode Nodes Selected...')
            return

        #判断是否选择了Shuffle
        if len(nuke.selectedNodes('Shuffle')):
            self.flag=True
        else:
            self.flag=False


        #获取BackdropNode的大小
        _bd_w=_bd.knob('bdwidth').value()
        _bd_h=_bd.knob('bdheight').value()

        #获取BackdropNode的位置
        _bd_pos=[_bd.xpos(),_bd.ypos()]
        #以第一个素材为例,定义素材的格式_w,_h
        _node=_source[0]
        #素材大小
        _w=_node.knob('format').value().width()
        _h=_node.knob('format').value().height()

        #素材屏幕大小
        _bbox=[_node.screenWidth(),_node.screenHeight()]
        _pos=[_node.xpos(),_node.ypos()]

        #判断素材的格式是否为EXR
        myfileFlagEXR=False

        myfileName=_source[0]['file'].value()    
        myfileNameType = os.path.splitext(myfileName)[1]
        if myfileNameType:
            if myfileNameType.find('exr')>=0:
                myfileFlagEXR=True


        #常见节点,并设置它的坐标为第一个素材的节点的位置
        if not myfileFlagEXR:
            return

        _dot_bd=nuke.nodes.Dot()
        _dot_bd.setXYpos(_bd_pos[0]+int(_bd_w),_bd_pos[1]+int(_bd_h))

        if const_split:
            starframes=_contactSheet.knob('startframe').value()
            endframes=_contactSheet.knob('endframe').value()
            _contactSheet_1 = nuke.nodes.ContactSheet(width=conts_width,height=conts_height,rows=conts_w,columns=conts_h,roworder=conts_row,colorder=const_color,splitinputs=True,startframe=starframes,endframe=endframes).name()
        else:
            _contactSheet_1 = nuke.nodes.ContactSheet(width=conts_width,height=conts_height,rows=conts_w,columns=conts_h,roworder=conts_row,colorder=const_color,splitinputs=False).name()  

        _node_1 = nuke.toNode(_contactSheet_1)

        #在所有的尺寸格式中,寻找跟素材一样的样式,在创建黑板,并设置位置
        _allFormat = nuke.formats()
        for _eachFormat in _allFormat:
               if _eachFormat.width()==_w and _eachFormat.height()==_h:
                   _constant_1=nuke.nodes.Constant(format=_eachFormat.name()).name()
                   _node_1=nuke.toNode(_constant_1)
        
        _sheetNode_1= nuke.toNode(_contactSheet_1)
        _conNode_1=nuke.toNode(_constant_1)

        for _x in range(18):
            _sheetNode_1.setInput(_x,_conNode_1)

        mii=0
        newMyShuffle_clone=[]
        for each in  _source:
            if mii==0:
                #创建管道
                myShuffle_1=nuke.nodes.Shuffle()

                myShuffle_1['in'].setValue(layer)
                myShuffle_1['hide_input'].setValue(True)
                for i in range(18):
                    if self.flag:
                        if _contactSheet.input(i).input(0)==each:
                            myShuffle_1.setInput(0,each)
                            #方格与管道连接
                            _sheetNode_1.setInput(i,myShuffle_1)
                            #设置管道的位置
                            myS_w=each.xpos()-_bd_X
                            myS_h=each.ypos()
                            myShuffle_1.setXYpos(_dot_bd.xpos()+myS_w+10,myS_h)
                            break
                    else:
                        if _contactSheet.input(i)==each:
                            #管道与Read节点连接
                            myShuffle_1.setInput(0,each)
                            #方格与管道连接
                            _sheetNode_1.setInput(i,myShuffle_1)
                            #设置管道的位置
                            myS_w=each.xpos()-_bd_X
                            myS_h=each.ypos()
                            myShuffle_1.setXYpos(_dot_bd.xpos()+myS_w+10,myS_h)
                            break
            else:
                self.setSelecteNone()
                newMyShuffle_1 = nuke.clone(myShuffle_1)
                for i in range(18):
                    if self.flag:
                        if _contactSheet.input(i).input(0)==each:
                            newMyShuffle_1.setInput(0, each)
                            _sheetNode_1.setInput(i, newMyShuffle_1)
                            myS_w=each.xpos()-_bd_X
                            myS_h=each.ypos()
                            newMyShuffle_1.setXYpos(_dot_bd.xpos()+myS_w+10,int(myS_h))
                            newMyShuffle_clone.append(newMyShuffle_1)
                            break  
                    else:
                        if _contactSheet.input(i)==each:
                            newMyShuffle_1.setInput(0, each)
                            _sheetNode_1.setInput(i, newMyShuffle_1)
                            myS_w=each.xpos()-_bd_X
                            myS_h=each.ypos()
                            newMyShuffle_1.setXYpos(_dot_bd.xpos()+myS_w+10,int(myS_h))
                            newMyShuffle_clone.append(newMyShuffle_1)
                            break

            mii=mii+1
        for each in _source:
            each.setSelected(False)

        #创建背板,并设置名字,
        cs_w=_contactSheet.xpos()-_bd.xpos()
        cs_h=_contactSheet.ypos()
        _sheetNode_1.setXYpos(_dot_bd.xpos()+cs_w+10,cs_h)
        #_sheetNode_1.setInput(0,_contactSheet)

        const_w=_constant.xpos()-_bd.xpos()
        const_h=_constant.ypos()
        _conNode_1.setXYpos(_dot_bd.xpos()+const_w+10,const_h)

        #删除黑板
        conUsed = _conNode_1.dependent()
       # print conUsed

        if not conUsed:
            nuke.delete(_conNode_1)
        else:
            _conNode_1.setSelected(1)

        nuke.delete(_dot_bd)

        for shuffle in newMyShuffle_clone:
            shuffle.setSelected(True)
        _sheetNode_1.setSelected(True)
       
        _conNode_1.setSelected(True)
        myShuffle_1.setSelected(True)
        newMyShuffle_1.setSelected(True)

        myOldbdWidth_1=backDropStr.knob('bdwidth').value()
        myOldbdHeight_1=backDropStr.knob('bdheight').value()
        bd_1 = nukescripts.autoBackdrop()
        bd_1.knob('label').setValue(_backDropStr+'_'+layer)

        #myOldbdHeight_1 = bd_1.knob('bdheight').value()
        #myOldbdWidth_1=bd_1.knob('bdwidth').value()
        bd_1.knob('bdheight').setValue(myOldbdHeight_1) 
        bd_1.knob('bdwidth').setValue(myOldbdWidth_1) 
      
        bd_1.setSelected(True)
Пример #7
0
    def mergeCamera(self, mymodel):
        self.mode = mymodel
        #定义_source为所选的素材、_contactSheet方格 _constant黑板 _backDropStr背板、保存的摄像机字典
        _source = nuke.selectedNodes('Read')
        self.numSelect = len(_source)
        _contactSheet, _constant, _backDropStr = '', '', ''
        _sortedCam = {}

        #搜索所选的内容
        if len(nuke.selectedNodes('ContactSheet')):
            _contactSheet = nuke.selectedNodes('ContactSheet')[0]

        if len(nuke.selectedNodes('Constant')):
            _constant = nuke.selectedNodes('Constant')[0]

        if len(_source) == 0:
            nuke.message("No Read Nodes Selected...")
            return

        #以第一个素材为例,定义素材的格式_w  _h
        #相对于nuke的节点大小_bbox, 节点的位置_pos
        _node = _source[0]
        _w = _node.knob('format').value().width()
        _h = _node.knob('format').value().height()
        _bbox = [_node.screenWidth(), _node.screenHeight()]
        _pos = [_node.xpos(), _node.ypos()]

        #常见点节点,并设置它的坐标为第一个素材的节点位置
        _dot = nuke.nodes.Dot()
        _dot.setXYpos(_pos[0], _pos[1])
        if self.numSelect <= 9:
            _pattern = ((-1, -2), (-0, -2), (1, -2), \
                        (-1, -1), (0, -1), (1, -1), \
                        (-1, 0), (0, 0), (1, 0))
        else:
            _pattern = ((-3, -2), (-2, -2), (-1, -2), (0, -2), (1, -2), (2, -2), \
                        (-3, -1), (-2, -1), (-1, -1), (0, -1), (1, -1), (2, -1), \
                        (-3, 0), (-2, 0), (-1, 0), (0, 0), (1, 0), (2, 0))

        #查找输出尺寸
        # _format = nuke.knob("format").split()
        #当方格为空时创建方格,并设置它的位置
        if _contactSheet == "":
            if self.numSelect <= 9:
                _contactSheet = nuke.nodes.ContactSheet(
                    width=_w * 3,
                    height=_h * 3,
                    rows=3,
                    columns=3,
                    roworder='TopBottom').name()
            else:
                _contactSheet = nuke.nodes.ContactSheet(
                    width=_w * 6,
                    height=_h * 3,
                    rows=3,
                    columns=6,
                    roworder='TopBottom').name()
            _node = nuke.toNode(_contactSheet)
            _node.setXYpos(_dot.xpos() + _bbox[0] * 0,
                           _dot.ypos() + _bbox[1] * 2)
        #在所有的尺寸格式中,寻找跟素材一样样式,在创建黑板,并设置位置
        if _constant == "":
            _allFormat = nuke.formats()
            for _eachFormat in _allFormat:
                if _eachFormat.width() == _w and _eachFormat.height() == _h:
                    _constant = nuke.nodes.Constant(
                        format=_eachFormat.name()).name()
                    _node = nuke.toNode(_constant)
                    #_node.setXYpos(_dot.xpos()+_bbox[0]*1,_dot.ypos()+_bbox[1]*-1)

        #在每个素材中记录摄像机,且记录背板的名字
        for each in _source:
            camStr = self.checkFile(each)
            if camStr:
                _sortedCam[camStr[0]] = each
                if not _backDropStr:
                    _backDropStr = camStr[1]
            else:
                each.setSelected(False)

        _sheetNode = nuke.toNode(_contactSheet)

        _conNode = nuke.toNode(_constant)

        if self.numSelect <= 9:
            for _x in range(9):
                _sheetNode.setInput(_x, _conNode)
        else:
            for _x in range(18):
                _sheetNode.setInput(_x, _conNode)
        #判断素材的格式
        myfileFlagEXR = False
        myfileName = _source[0]['file'].value()
        myfileNameType = os.path.splitext(myfileName)[1]
        if myfileNameType:
            if myfileNameType.find('exr') >= 0:
                myfileFlagEXR = True
        myii = 0
        for _k, _v in _sortedCam.iteritems():
            _sourceNode = _v
            #查找摄像机相对应的方格通道,链接,并调整位置
            if _k[0] == "_":
                myKey = _k[1::]
            else:
                myKey = _k

            #当时exr时,添加shuffle通道节点
            if self.mode == 1:
                _sheetNode.setInput(self.num[myKey] - 1, _sourceNode)
                _pick = _pattern[self.num[myKey] - 1]
                _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                     _bbox[1] * _pick[1] + _dot.ypos())
            #当时exr时,根据需要添加shuffle通道节点
            elif self.mode == 2:
                _pick = _pattern[self.num[myKey] - 1]
                _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                     _bbox[1] * _pick[1] + _dot.ypos())
                if not myfileFlagEXR:
                    _sheetNode.setInput(self.num[myKey] - 1, _sourceNode)
                    _sourceNode.setSelected(1)
                else:
                    if myii == 0:
                        myShuffle = nuke.nodes.Shuffle()
                        myShuffle.setInput(0, _sourceNode)
                        _sheetNode.setInput(self.num[myKey] - 1, myShuffle)
                        myShuffle.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                           _bbox[1] * _pick[1] + _dot.ypos())
                    else:
                        self.setSelecteNone()
                        newMyShuffle = nuke.clone(myShuffle)
                        newMyShuffle.setInput(0, _sourceNode)
                        _sheetNode.setInput(self.num[myKey] - 1, newMyShuffle)
                        newMyShuffle.setXYpos(
                            _bbox[0] * _pick[0] + _dot.xpos(),
                            _bbox[1] * _pick[1] + _dot.ypos())
            # _pick = _pattern[self.num[myKey]-1]
            # _sourceNode.setXYpos(_bbox[0]*_pick[0]+_dot.xpos(),_bbox[1]*_pick[1]+_dot.ypos()+20)
            # myShuffle.setSelected(1)
            # _sourceNode.setSelected(1)
            myii = myii + 1
        _sheetNode.setSelected(1)

        for each in _source:
            each.setSelected(1)
        #创建背板,并设置名字,
        #bd = nukescripts.autoBackdrop()
        #bd.knob('label').setValue(_backDropStr)
        _sheetNode.setXYpos(_dot.xpos() + _bbox[0] * 0,
                            _dot.ypos() + _bbox[1] * 1)
        if self.numSelect == 5:
            _conNode.setXYpos(_dot.xpos() + _bbox[0] * 1,
                              _dot.ypos() + _bbox[1] * 1 - 50)
        else:
            _conNode.setXYpos(_dot.xpos() + _bbox[0] * 1 + 86,
                              _dot.ypos() + _bbox[1] * 1 - 45)

        #删除黑板
        conUsed = _conNode.dependent()

        if not conUsed:
            nuke.delete(_conNode)
        else:
            _conNode.setSelected(1)

        nuke.delete(_dot)
        bd = nukescripts.autoBackdrop()
        bd.knob('label').setValue(_backDropStr)
        myOldbdHeight = bd.knob('bdheight').value()
        bd.knob('bdheight').setValue(myOldbdHeight + 15)
Пример #8
0
    def mergeCamera(self, flag, mymodel):
        self.mode = mymodel

        #选择所有的节点
        _source = nuke.selectedNodes('Read')
        self.numSelect = len(_source)
        #定义_contactSheet方格 _constant黑板 _backDropStr背板、保存的摄像机字典
        _contactSheet, _constant, _backDropStr = '', '', ''
        _sortedCam = {}

        #搜索所选的内容
        if len(nuke.selectedNodes('ContactSheet')):
            _contactSheet = nuke.selectedNodes('ContactSheet')[0]
        if len(nuke.selectedNodes('Constant')):
            _constant = nuke.selectedNodes('Constant')[0]

        if len(_source) == 0:
            nuke.message('No Read Nodes Selected...')
            return
        if len(_source) != flag:
            nuke.message(
                '\xe4\xbd\xa0\xe6\x89\x80\xe9\x80\x89\xe6\x8b\xa9\xe7\x9a\x84\xe7\xb4\xa0\xe6\x9d\x90\xe4\xb8\xaa\xe6\x95\xb0\xe4\xb8\x8e\xe4\xbd\xa0\xe9\x80\x89\xe6\x8b\xa9\xe7\x9a\x84\xe5\x90\x88\xe5\xb9\xb6\xe9\x80\x89\xe9\xa1\xb9\xe4\xb8\x8d\xe7\x9b\xb8\xe5\x90\x8c'
            )
            return

        #以所选的第一个素材为例,定义素材的格式_w _h
        _node = _source[0]
        #获取第一个素材在nuke中的位置
        _w = _node.knob('format').value().width()

        _h = _node.knob('format').value().height()

        #获取第一个素材的大小
        _bbox = [_node.screenWidth(), _node.screenHeight()]
        _pos = [_node.xpos(), _node.ypos()]

        #常见点节点,并设置它的坐标为第一个素材的节点位置
        _dot = nuke.nodes.Dot()
        _dot.setXYpos(_pos[0], _pos[1])

        _pattern = ''
        if self.numSelect <= 3:
            _pattern = ((-1, 0), (0, 0), (1, 0))

        elif self.numSelect == 6:
            _pattern=((-2,-2),(-1,-2),(0,-2),(1,-2),\
                (-2,-1),(-1,-1),(0,-1),(1,-1),\
                (-2,0),(-1,0),(0,0),(1,0))

        #当方格为空时,并设置它的坐标为第一个素材的节点位置
        if _contactSheet == "":
            if self.numSelect <= 3:
                _contactSheet = nuke.nodes.ContactSheet(
                    width=_w * 3,
                    height=_h * 1,
                    rows=1,
                    columns=3,
                    roworder='TopButtom').name()
            elif self.numSelect == 6:
                _contactSheet = nuke.nodes.ContactSheet(
                    width=_w * 4,
                    height=_h * 3,
                    rows=3,
                    columns=4,
                    roworder='TopButtom').name()

            _node = nuke.toNode(_contactSheet)
            _node = _node.setXYpos(_dot.xpos() + _bbox[0] * 0,
                                   _dot.ypos() + _bbox[1] * 2)

        #在所有的尺寸格式中,寻找跟素材一样样式,在创建黑板,并设置位置
        if _constant == "":
            _allFormat = nuke.formats()
            for _eachFormat in _allFormat:
                if _eachFormat.width() == _w and _eachFormat.height() == _h:
                    _constant = nuke.nodes.Constant(
                        format=_eachFormat.name()).name()
                    _node = nuke.toNode(_constant)

        #在每个素材中记录摄像机,并记录黑板的名字
        for each in _source:
            camStr = self.checkFile(each)
            if camStr:
                _sortedCam[camStr[0]] = each
                if not _backDropStr:
                    _backDropStr = camStr[1]
                else:
                    each.setSelected(False)
        _sheeNode = nuke.toNode(_contactSheet)
        _conNode = nuke.toNode(_constant)

        #根据所选的素材的个数创建ContactSheet和Constant连接的线
        if self.numSelect == 3:
            for _x in range(9):
                _sheeNode.setInput(_x, _conNode)
        else:
            for _x in range(18):
                _sheeNode.setInput(_x, _conNode)
        #判断素材的格式
        myfileFlagEXR = False
        #查询第一个素材的路径
        myfileName = _source[0]['file'].value()
        #获取素材的格式
        myfileNameType = os.path.splitext(myfileName)[1]
        if myfileNameType:
            if myfileNameType.find('exr') >= 0:
                myfileFlagEXR = True

        myii = 0
        for _k, _v in _sortedCam.iteritems():
            _sourceNode = _v
            #查找摄像机对应的方格通道,链接,并调整位置
            if _k[0] == "_":
                myKey = _k[1::]
            else:
                myKey = _k

            #当时exr时,添加shuffle通道节点
            if self.mode == 1:
                if self.numSelect == 3:
                    _sheeNode.setInput(self.num[myKey] - 1, _sourceNode)
                    _pick = _pattern[self.num[myKey] - 1]
                    #设置素材的在nuke中的位置
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())
                elif self.numSelect == 6:
                    _sheeNode.setInput(self.num6[myKey] - 1, _sourceNode)
                    _pick = _pattern[self.num6[myKey] - 1]
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())

            #当时exr时,根据需要添加shuffle通道节点
            elif self.mode == 2:
                if self.numSelect == 3:
                    _pick = _pattern[self.num[myKey] - 1]
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())
                    if not myfileFlagEXR:
                        _sheeNode.setInput(self.num[myKey] - 1, _sourceNode)
                        _sourceNode.setSelected(1)
                    else:
                        if myii == 0:
                            myShuffle = nuke.nodes.Shuffle()
                            myShuffle.setInput(0, _sourceNode)
                            _sheeNode.setInput(self.num[myKey] - 1, myShuffle)
                            myShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                        else:
                            self.setSelecteNone()
                            newMyShuffle = nuke.clone(myShuffle)
                            newMyShuffle.setInput(0, _sourceNode)
                            _sheeNode.setInput(self.num[myKey] - 1,
                                               newMyShuffle)
                            newMyShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())

                elif self.numSelect == 6:
                    _pick = _pattern[self.num6[myKey] - 1]
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())
                    if not myfileFlagEXR:
                        _sheeNode.setInput(self.num6[myKey] - 1, _sourceNode)
                        _sourceNode.setSelected(1)
                    else:
                        if myii == 0:
                            myShuffle = nuke.nodes.Shuffle()
                            myShuffle.setInput(0, _sourceNode)
                            _sheeNode.setInput(self.num6[myKey] - 1, myShuffle)
                            myShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                        else:
                            self.setSelecteNone()
                            newMyShuffle = nuke.clone(myShuffle)
                            newMyShuffle.setInput(0, _sourceNode)
                            _sheeNode.setInput(self.num6[myKey] - 1,
                                               newMyShuffle)
                            newMyShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())

            myii = myii + 1
        _sheeNode.setSelected(1)

        for each in _source:
            each.setSelected(1)
        if self.numSelect == 3:
            _sheeNode.setXYpos(_dot.xpos() + _bbox[0] * 0,
                               _dot.ypos() + _bbox[1] * 2 - 30)
            _conNode.setXYpos(_dot.xpos() + _bbox[0] * 1,
                              _dot.ypos() + _bbox[1] * 1 - 10)

        elif self.numSelect == 6:
            _sheeNode.setXYpos(_dot.xpos() + _bbox[0] * 0 - 45,
                               _dot.ypos() + _bbox[1] * 1)
            _conNode.setXYpos(_dot.xpos() + 10, _dot.ypos() + 10)

        #if self.numSelect==3:
        #_conNode.setXYpos(_dot.xpos()+_bbox[0]*1,_dot.ypos()+_bbox[1]*1-10)

        #删除黑板
        conUsed = _conNode.dependent()

        if not conUsed:
            nuke.delete(_conNode)
        else:
            _conNode.setSelected(1)

        nuke.delete(_dot)
        bd = nukescripts.autoBackdrop()
        bd.knob('label').setValue(_backDropStr)
        myOldbdHeight = bd.knob('bdheight').value()
        bd.knob('bdheight').setValue(myOldbdHeight + 15)
Пример #9
0
    def mergeCamera(self, flag, mymodel, FileName):
        self.mode = mymodel

        #选择所有的节点
        _source = nuke.selectedNodes('Read')
        self.numSelect = len(_source)

        # ===== add by zhangben 2018 12 12 =================for DNTG===============
        if FileName == "DNTG" and flag == 3:
            self.mergeCams_dntg(_source, flag, FileName)
            return

        #定义_contactSheet方格 _constant黑板 _backDropStr背板、保存的摄像机字典
        _contactSheet, _constant, _backDropStr = '', '', ''
        _sortedCam = {}

        #搜索所选的内容
        if len(nuke.selectedNodes('ContactSheet')):
            _contactSheet = nuke.selectedNodes('ContactSheet')[0]
        if len(nuke.selectedNodes('Constant')):
            _constant = nuke.selectedNodes('Constant')[0]

        if len(_source) == 0:
            nuke.message('No Read Nodes Selected...')
            return
        if len(_source) != flag and (flag == 6 and flag < len(_source) and
                                     (FileName != "CPSH"
                                      or FileName != " FKBS")
                                     and FileName != "SGFC"):
            nuke.message(
                '\xe4\xbd\xa0\xe6\x89\x80\xe9\x80\x89\xe6\x8b\xa9\xe7\x9a\x84\xe7\xb4\xa0\xe6\x9d\x90\xe4\xb8\xaa\xe6\x95\xb0\xe4\xb8\x8e\xe4\xbd\xa0\xe9\x80\x89\xe6\x8b\xa9\xe7\x9a\x84\xe5\x90\x88\xe5\xb9\xb6\xe9\x80\x89\xe9\xa1\xb9\xe4\xb8\x8d\xe7\x9b\xb8\xe5\x90\x8c'
            )
            return

        #以所选的第一个素材为例,定义素材的格式_w _h
        _node = _source[0]
        #获取第一个素材在nuke中的位置
        _w = _node.knob('format').value().width()

        _h = _node.knob('format').value().height()

        #获取第一个素材的大小
        _bbox = [_node.screenWidth(), _node.screenHeight()]
        _pos = [_node.xpos(), _node.ypos()]

        #常见点节点,并设置它的坐标为第一个素材的节点位置
        _dot = nuke.nodes.Dot()
        _dot.setXYpos(_pos[0], _pos[1])

        _pattern = ''
        if self.numSelect <= 3 and FileName == "":
            _pattern = ((-1, 0), (0, 0), (1, 0))

        elif self.numSelect == 4 and FileName == "":
            _pattern=((-1,-1),(0,-1),(1,-1),\
                (-1,0),(0,0),(1,0))

        elif self.numSelect <= 6 and FileName == "CPSH":
            _pattern=((-2,-2),(-1,-2),(0,-2),(1,-2),\
                (-2,-1),(-1,-1),(0,-1),(1,-1),\
                (-2,0),(-1,0),(0,0),(1,0))
        elif self.numSelect <= 6 and FileName == "FKBS":
            _pattern = ((-3, 0), (-2, 0), (-1, 0), (0, 0), (1, 0), (2, 0))

        elif FileName == "SGFC" and flag == 5:
            _pattern=((-1,-2),(0,-2),(1,-2),\
                     (-1,-1),(0,-1),(1,-1),\
                     (-1,0),(0,0),(1,0))

        #当方格为空时,并设置它的坐标为第一个素材的节点位置
        if _contactSheet == "":
            if self.numSelect <= 3 and FileName == "":
                _contactSheet = nuke.nodes.ContactSheet(
                    width=_w * 3,
                    height=_h * 1,
                    rows=1,
                    columns=3,
                    roworder='TopButtom').name()
            elif self.numSelect == 4 and FileName == "":
                _contactSheet = nuke.nodes.ContactSheet(
                    width=_w * 3,
                    height=_w * 2,
                    rows=2,
                    columns=3,
                    roworder='TopButtom').name()

            elif self.numSelect <= 6 and FileName == "CPSH":
                _contactSheet = nuke.nodes.ContactSheet(
                    width=_w * 4,
                    height=_h * 3,
                    rows=3,
                    columns=4,
                    roworder='TopButtom').name()

            elif self.numSelect <= 6 and FileName == "FKBS":
                _contactSheet = nuke.nodes.ContactSheet(
                    width=_w * 6,
                    height=_h,
                    rows=1,
                    columns=6,
                    roworder='TopButtom').name()

            elif FileName == "SGFC":
                _contactSheet = nuke.nodes.ContactSheet(
                    width=_w * 3,
                    height=_h * 3,
                    rows=3,
                    columns=3,
                    roworder='TopButtom').name()

            _node = nuke.toNode(_contactSheet)
            _node = _node.setXYpos(_dot.xpos() + _bbox[0] * 0,
                                   _dot.ypos() + _bbox[1] * 2)

        #在所有的尺寸格式中,寻找跟素材一样样式,在创建黑板,并设置位置
        if _constant == "":
            _allFormat = nuke.formats()
            for _eachFormat in _allFormat:
                if _eachFormat.width() == _w and _eachFormat.height() == _h:
                    _constant = nuke.nodes.Constant(
                        format=_eachFormat.name()).name()
                    _node = nuke.toNode(_constant)
                    break

        if self.numSelect == 4 and FileName == "":
            myCrop = nuke.nodes.Crop()
            myCrop['box'].setValue([0, _w / 2, _w * 3, _w * 2])
            myCrop['reformat'].setValue(True)
            _allFormat = nuke.formats()
            for _eachFormat in _allFormat:
                if _eachFormat.width() == _w and _eachFormat.height() == _h:
                    _constant1 = nuke.nodes.Constant(
                        format=_eachFormat.name()).name()
                    _node1 = nuke.toNode(_constant1)
                    if not _eachFormat.name():
                        widthHeight = str(_w) + " " + str(_h)
                        square = widthHeight + " " + "myCrops"
                        nuke.addFormat(square)
                        _node1['format'].setValue("myCrops")
                    break

        #在每个素材中记录摄像机,并记录黑板的名字
        for each in _source:
            camStr = self.checkFile(each, FileName)
            if camStr:
                _sortedCam[camStr[0]] = each
                if not _backDropStr:
                    _backDropStr = camStr[1]
                else:
                    each.setSelected(False)
        _sheeNode = nuke.toNode(_contactSheet)
        _conNode = nuke.toNode(_constant)

        #根据所选的素材的个数创建ContactSheet和Constant连接的线
        if self.numSelect == 3 and FileName == "":
            for _x in range(9):
                _sheeNode.setInput(_x, _conNode)
        else:
            for _x in range(18):
                _sheeNode.setInput(_x, _conNode)
        if self.numSelect == 4 and FileName == "":
            myCrop.setInput(0, _sheeNode)

        #判断素材的格式
        myfileFlagEXR = False
        #查询第一个素材的路径
        myfileName = _source[0]['file'].value()
        #获取素材的格式
        myfileNameType = os.path.splitext(myfileName)[1]
        if myfileNameType:
            if myfileNameType.find('exr') >= 0:
                myfileFlagEXR = True

        myii = 0
        myMer = 0
        for _k, _v in _sortedCam.iteritems():
            #print _k
            #print _v
            _sourceNode = _v
            #查找摄像机对应的方格通道,链接,并调整位置
            if _k[0] == "_":
                myKey = _k[1::]
            else:
                myKey = _k
            #print myKey
            #当时exr时,添加shuffle通道节点
            if self.mode == 1:
                if self.numSelect == 3 and FileName == "":
                    _sheeNode.setInput(self.num[myKey] - 1, _sourceNode)
                    _pick = _pattern[self.num[myKey] - 1]
                    #设置素材的在nuke中的位置
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())

                #FKBS特殊的比例相机
                elif self.numSelect == 4 and FileName == "":
                    if _sourceNode.knob('format').value().height(
                    ) == _sourceNode.knob('format').value().width() / 2:
                        _pick = _pattern[self.num4[myKey] - 1]
                        if myMer == 0:
                            TransformNode = nuke.nodes.Transform()
                            MergeNode = nuke.nodes.Merge2()
                            MergeNode.setInput(1, TransformNode)
                            TransformNode['translate'].setValue([
                                0,
                                _sourceNode.knob('format').value().height()
                            ])
                            TransformNode.setInput(0, _sourceNode)

                            _sheeNode.setInput(self.num4[myKey] - 1, MergeNode)
                            MergeNode.setInput(0, _node1)
                            MergeNode.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                            TransformNode.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                            _sourceNode.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                        else:
                            TransformNode = nuke.nodes.Transform()
                            self.setSelecteNone()
                            newMergeNode = nuke.clone(MergeNode)
                            newMergeNode.setInput(1, TransformNode)
                            TransformNode['translate'].setValue([
                                0,
                                _sourceNode.knob('format').value().height()
                            ])
                            TransformNode.setInput(0, _sourceNode)

                            _sheeNode.setInput(self.num4[myKey] - 1,
                                               newMergeNode)
                            newMergeNode.setInput(0, _node1)
                            newMergeNode.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                            TransformNode.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                            _sourceNode.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                        myMer = myMer + 1
                    else:
                        _sheeNode.setInput(self.num4[myKey] - 1, _sourceNode)
                        _pick = _pattern[self.num4[myKey] - 1]
                        _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                             _bbox[1] * _pick[1] + _dot.ypos())

                elif self.numSelect <= 6 and FileName == "CPSH":
                    # print myKey
                    _sheeNode.setInput(self.num6[myKey] - 1, _sourceNode)
                    _pick = _pattern[self.num6[myKey] - 1]
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())

                elif self.numSelect <= 6 and FileName == "FKBS":
                    # print myKey
                    # print self.FKBSNum6[myKey]
                    # print _pattern
                    _pattern[self.FKBSNum6[myKey] - 1]
                    _sheeNode.setInput(self.FKBSNum6[myKey] - 1, _sourceNode)
                    _pick = _pattern[self.FKBSNum6[myKey] - 1]
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())

                if FileName == "SGFC":
                    _sheeNode.setInput(self.SGFCNum5[myKey] - 1, _sourceNode)
                    _pick = _pattern[self.SGFCNum5[myKey] - 1]
                    #设置素材的在nuke中的位置
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())

            #当时exr时,根据需要添加shuffle通道节点
            elif self.mode == 2:
                if self.numSelect == 3 and FileName == "":
                    _pick = _pattern[self.num[myKey] - 1]
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())
                    if not myfileFlagEXR:
                        _sheeNode.setInput(self.num[myKey] - 1, _sourceNode)
                        _sourceNode.setSelected(1)
                    else:
                        if myii == 0:
                            myShuffle = nuke.nodes.Shuffle()
                            myShuffle.setInput(0, _sourceNode)
                            _sheeNode.setInput(self.num[myKey] - 1, myShuffle)
                            myShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                        else:
                            self.setSelecteNone()
                            newMyShuffle = nuke.clone(myShuffle)
                            newMyShuffle.setInput(0, _sourceNode)
                            _sheeNode.setInput(self.num[myKey] - 1,
                                               newMyShuffle)
                            newMyShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())

                #FKBS特殊的比例相机
                elif self.numSelect == 4 and FileName == "":
                    _pick = _pattern[self.num4[myKey] - 1]
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())
                    if not myfileFlagEXR:
                        if _sourceNode.knob('format').value().height(
                        ) == _sourceNode.knob('format').value().width() / 2:
                            if myMer == 0:
                                TransformNode = nuke.nodes.Transform()
                                MergeNode = nuke.nodes.Merge2()
                                MergeNode.setInput(1, TransformNode)
                                TransformNode['translate'].setValue([
                                    0,
                                    _sourceNode.knob(
                                        'format').value().height()
                                ])
                                TransformNode.setInput(0, _sourceNode)

                                _sheeNode.setInput(self.num4[myKey] - 1,
                                                   MergeNode)
                                MergeNode.setInput(0, _node1)
                                MergeNode.setXYpos(
                                    _bbox[0] * _pick[0] + _dot.xpos(),
                                    _bbox[1] * _pick[1] + _dot.ypos())
                                TransformNode.setXYpos(
                                    _bbox[0] * _pick[0] + _dot.xpos(),
                                    _bbox[1] * _pick[1] + _dot.ypos())
                                myShuffle.setXYpos(
                                    _bbox[0] * _pick[0] + _dot.xpos(),
                                    _bbox[1] * _pick[1] + _dot.ypos())
                                _sourceNode.setSelected(1)
                            else:
                                TransformNode = nuke.nodes.Transform()
                                self.setSelecteNone()
                                newMergeNode = nuke.clone(MergeNode)
                                newMergeNode.setInput(1, TransformNode)
                                TransformNode['translate'].setValue([
                                    0,
                                    _sourceNode.knob(
                                        'format').value().height()
                                ])
                                TransformNode.setInput(0, _sourceNode)

                                _sheeNode.setInput(self.num4[myKey] - 1,
                                                   newMergeNode)
                                newMergeNode.setInput(0, _node1)
                                newMergeNode.setXYpos(
                                    _bbox[0] * _pick[0] + _dot.xpos(),
                                    _bbox[1] * _pick[1] + _dot.ypos())
                                TransformNode.setXYpos(
                                    _bbox[0] * _pick[0] + _dot.xpos(),
                                    _bbox[1] * _pick[1] + _dot.ypos())
                                myShuffle.setXYpos(
                                    _bbox[0] * _pick[0] + _dot.xpos(),
                                    _bbox[1] * _pick[1] + _dot.ypos())
                                _sourceNode.setSelected(1)
                            myMer = myMer + 1
                        else:
                            _sheeNode.setInput(self.num4[myKey] - 1,
                                               _sourceNode)
                            _pick = _pattern[self.num4[myKey] - 1]
                            _sourceNode.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())

                    else:
                        if myii == 0:
                            if _sourceNode.knob('format').value().height(
                            ) == _sourceNode.knob(
                                    'format').value().width() / 2:
                                if myMer == 0:
                                    TransformNode = nuke.nodes.Transform()
                                    MergeNode = nuke.nodes.Merge2()
                                    MergeNode.setInput(1, TransformNode)
                                    TransformNode['translate'].setValue([
                                        0,
                                        _sourceNode.knob(
                                            'format').value().height()
                                    ])

                                    myShuffle = nuke.nodes.Shuffle()

                                    TransformNode.setInput(0, _sourceNode)

                                    myShuffle.setInput(0, MergeNode)

                                    _sheeNode.setInput(self.num4[myKey] - 1,
                                                       myShuffle)

                                    MergeNode.setInput(0, _node1)
                                    MergeNode.setXYpos(
                                        _bbox[0] * _pick[0] + _dot.xpos(),
                                        _bbox[1] * _pick[1] + _dot.ypos())
                                    TransformNode.setXYpos(
                                        _bbox[0] * _pick[0] + _dot.xpos(),
                                        _bbox[1] * _pick[1] + _dot.ypos())
                                    myShuffle.setXYpos(
                                        _bbox[0] * _pick[0] + _dot.xpos(),
                                        _bbox[1] * _pick[1] + _dot.ypos())

                                else:
                                    TransformNode = nuke.nodes.Transform()
                                    self.setSelecteNone()
                                    newMergeNode = nuke.clone(MergeNode)
                                    newMergeNode.setInput(1, TransformNode)
                                    TransformNode['translate'].setValue([
                                        0,
                                        _sourceNode.knob(
                                            'format').value().height()
                                    ])
                                    TransformNode.setInput(0, _sourceNode)
                                    myShuffle = nuke.nodes.Shuffle()

                                    myShuffle.setInput(0, newMergeNode)
                                    _sheeNode.setInput(self.num4[myKey] - 1,
                                                       myShuffle)

                                    newMergeNode.setInput(0, _node1)
                                    newMergeNode.setXYpos(
                                        _bbox[0] * _pick[0] + _dot.xpos(),
                                        _bbox[1] * _pick[1] + _dot.ypos())
                                    TransformNode.setXYpos(
                                        _bbox[0] * _pick[0] + _dot.xpos(),
                                        _bbox[1] * _pick[1] + _dot.ypos())
                                    myShuffle.setXYpos(
                                        _bbox[0] * _pick[0] + _dot.xpos(),
                                        _bbox[1] * _pick[1] + _dot.ypos())
                                    _sourceNode.setSelected(1)

                            else:
                                myShuffle = nuke.nodes.Shuffle()
                                myShuffle.setInput(0, _sourceNode)
                                _sheeNode.setInput(self.num4[myKey] - 1,
                                                   myShuffle)
                                myShuffle.setXYpos(
                                    _bbox[0] * _pick[0] + _dot.xpos(),
                                    _bbox[1] * _pick[1] + _dot.ypos())
                        else:
                            if _sourceNode.knob('format').value().height(
                            ) == _sourceNode.knob(
                                    'format').value().width() / 2:
                                if myMer == 0:
                                    TransformNode = nuke.nodes.Transform()
                                    MergeNode = nuke.nodes.Merge2()
                                    MergeNode.setInput(1, TransformNode)
                                    TransformNode['translate'].setValue([
                                        0,
                                        _sourceNode.knob(
                                            'format').value().height()
                                    ])

                                    newMyShuffle = nuke.clone(myShuffle)

                                    TransformNode.setInput(0, _sourceNode)

                                    newMyShuffle.setInput(0, MergeNode)

                                    _sheeNode.setInput(self.num4[myKey] - 1,
                                                       newMyShuffle)

                                    MergeNode.setInput(0, _node1)
                                    MergeNode.setXYpos(
                                        _bbox[0] * _pick[0] + _dot.xpos(),
                                        _bbox[1] * _pick[1] + _dot.ypos())
                                    TransformNode.setXYpos(
                                        _bbox[0] * _pick[0] + _dot.xpos(),
                                        _bbox[1] * _pick[1] + _dot.ypos())
                                    newMyShuffle.setXYpos(
                                        _bbox[0] * _pick[0] + _dot.xpos(),
                                        _bbox[1] * _pick[1] + _dot.ypos())

                                else:
                                    TransformNode = nuke.nodes.Transform()
                                    self.setSelecteNone()
                                    newMergeNode = nuke.clone(MergeNode)
                                    newMergeNode.setInput(1, TransformNode)
                                    TransformNode['translate'].setValue([
                                        0,
                                        _sourceNode.knob(
                                            'format').value().height()
                                    ])
                                    TransformNode.setInput(0, _sourceNode)
                                    newMyShuffle = nuke.clone(myShuffle)

                                    myShuffle.setInput(0, newMyShuffle)
                                    _sheeNode.setInput(self.num4[myKey] - 1,
                                                       newMyShuffle)

                                    newMergeNode.setInput(0, _node1)
                                    newMergeNode.setXYpos(
                                        _bbox[0] * _pick[0] + _dot.xpos(),
                                        _bbox[1] * _pick[1] + _dot.ypos())
                                    TransformNode.setXYpos(
                                        _bbox[0] * _pick[0] + _dot.xpos(),
                                        _bbox[1] * _pick[1] + _dot.ypos())
                                    newMyShuffle.setXYpos(
                                        _bbox[0] * _pick[0] + _dot.xpos(),
                                        _bbox[1] * _pick[1] + _dot.ypos())
                                    _sourceNode.setSelected(1)

                            else:
                                self.setSelecteNone()
                                newMyShuffle = nuke.clone(myShuffle)
                                newMyShuffle.setInput(0, _sourceNode)
                                _sheeNode.setInput(self.num4[myKey] - 1,
                                                   newMyShuffle)
                                newMyShuffle.setXYpos(
                                    _bbox[0] * _pick[0] + _dot.xpos(),
                                    _bbox[1] * _pick[1] + _dot.ypos())

                elif self.numSelect <= 6 and FileName == "CPSH":
                    _pick = _pattern[self.num6[myKey] - 1]
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())
                    if not myfileFlagEXR:
                        _sheeNode.setInput(self.num6[myKey] - 1, _sourceNode)
                        _sourceNode.setSelected(1)
                    else:
                        if myii == 0:
                            myShuffle = nuke.nodes.Shuffle()
                            myShuffle.setInput(0, _sourceNode)
                            _sheeNode.setInput(self.num6[myKey] - 1, myShuffle)
                            myShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                        else:
                            self.setSelecteNone()
                            newMyShuffle = nuke.clone(myShuffle)
                            newMyShuffle.setInput(0, _sourceNode)
                            _sheeNode.setInput(self.num6[myKey] - 1,
                                               newMyShuffle)
                            newMyShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                elif self.numSelect <= 6 and FileName == 'FKBS':
                    _pick = _pattern[self.FKBSNum6[myKey] - 1]
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())
                    if not myfileFlagEXR:
                        _sheeNode.setInput(self.FKBSNum6[myKey] - 1,
                                           _sourceNode)
                        _sourceNode.setSelected(1)
                    else:
                        if myii == 0:
                            myShuffle = nuke.nodes.Shuffle()
                            myShuffle.setInput(0, _sourceNode)
                            _sheeNode.setInput(self.FKBSNum6[myKey] - 1,
                                               myShuffle)
                            myShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                        else:
                            self.setSelecteNone()
                            newMyShuffle = nuke.clone(myShuffle)
                            newMyShuffle.setInput(0, _sourceNode)
                            _sheeNode.setInput(self.FKBSNum6[myKey] - 1,
                                               newMyShuffle)
                            newMyShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())

                elif FileName == 'SGFC':
                    _pick = _pattern[self.SGFCNum5[myKey] - 1]
                    _sourceNode.setXYpos(_bbox[0] * _pick[0] + _dot.xpos(),
                                         _bbox[1] * _pick[1] + _dot.ypos())
                    if not myfileFlagEXR:
                        _sheeNode.setInput(self.SGFCNum5[myKey] - 1,
                                           _sourceNode)
                        _sourceNode.setSelected(1)
                    else:
                        if myii == 0:
                            myShuffle = nuke.nodes.Shuffle()
                            myShuffle.setInput(0, _sourceNode)
                            _sheeNode.setInput(self.SGFCNum5[myKey] - 1,
                                               myShuffle)
                            myShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())
                        else:
                            self.setSelecteNone()
                            newMyShuffle = nuke.clone(myShuffle)
                            newMyShuffle.setInput(0, _sourceNode)
                            _sheeNode.setInput(self.SGFCNum5[myKey] - 1,
                                               newMyShuffle)
                            newMyShuffle.setXYpos(
                                _bbox[0] * _pick[0] + _dot.xpos(),
                                _bbox[1] * _pick[1] + _dot.ypos())

            myii = myii + 1
        _sheeNode.setSelected(1)

        for each in _source:
            each.setSelected(1)
        if self.numSelect == 3 and FileName == "":
            _sheeNode.setXYpos(_dot.xpos() + _bbox[0] * 0,
                               _dot.ypos() + _bbox[1] * 2 - 30)
            _conNode.setXYpos(_dot.xpos() + _bbox[0] * 1,
                              _dot.ypos() + _bbox[1] * 1 - 10)

        elif self.numSelect == 4 and FileName == "":
            _sheeNode.setXYpos(_dot.xpos() + _bbox[0] * 0,
                               _dot.ypos() + _bbox[1] * 1)
            _conNode.setXYpos(_dot.xpos() + _bbox[0] * 1,
                              _dot.ypos() + _bbox[1] * 1 - 10)
            _node1.setXYpos(_dot.xpos() - _bbox[0] * 1,
                            _dot.ypos() + _bbox[1] * 1 - 10)
            myCrop.setXYpos(_dot.xpos() + _bbox[0] * 0,
                            _dot.ypos() + _bbox[1] * 1 + 30)

        elif self.numSelect <= 6 and FileName == "CPSH":
            _sheeNode.setXYpos(_dot.xpos() + _bbox[0] * 0 - 45,
                               _dot.ypos() + _bbox[1] * 1)
            _conNode.setXYpos(_dot.xpos() + 10, _dot.ypos() + 10)

        elif self.numSelect <= 6 and FileName == 'FKBS':
            _sheeNode.setXYpos(_dot.xpos() + _bbox[0] * 0 - 45,
                               _dot.ypos() + _bbox[1] * 2 - 30)
            _conNode.setXYpos(_dot.xpos() + _bbox[0] * 1,
                              _dot.ypos() + _bbox[1] * 1 - 10)

        elif FileName == 'SGFC':
            _sheeNode.setXYpos(_dot.xpos() + _bbox[0] * 0,
                               _dot.ypos() + _bbox[1] * 2 - 30)
            _conNode.setXYpos(_dot.xpos() + _bbox[0] * 1,
                              _dot.ypos() + _bbox[1] * 1 - 10)

        #if self.numSelect==3:
        #_conNode.setXYpos(_dot.xpos()+_bbox[0]*1,_dot.ypos()+_bbox[1]*1-10)

        #删除黑板
        conUsed = _conNode.dependent()

        if not conUsed:
            nuke.delete(_conNode)
        else:
            _conNode.setSelected(1)

        if self.numSelect == 4 and FileName == "":
            _node1.setSelected(1)
            myCrop.setSelected(1)

        nuke.delete(_dot)
        bd = nukescripts.autoBackdrop()
        bd.knob('label').setValue(_backDropStr)
        myOldbdHeight = bd.knob('bdheight').value()
        bd.knob('bdheight').setValue(myOldbdHeight + 30)