Example #1
0
 def _setup_rotomask(self):
     """Which partially covers the flower."""
     import nuke.rotopaint as rp
     self.gizmo.setInput(0, self.read_asset)
     rotomask = self.tempNode("Roto", inputs=[self.read_asset])
     shape = rp.Shape(rotomask['curves'])
     shape.getAttributes().set("fx", 20)
     shape.getAttributes().set("fy", 20)
     for pos in self.triangle_coords:
         shape.append(pos)
     rotomask['curves'].rootLayer.append(shape)
     return rotomask
def createContactSheet(shotFrame='start',
                       nbColumns=6,
                       seq="s0300",
                       taskname='compo_precomp'):
    res = findShots(seq=seq, taskname=taskname)
    shotPath = {}

    #find the directory where to put the output files
    fileOutPath = checkDir(path=_OUTPATH_, seq=seq)

    for entityName, fileTypes in res.items():
        #add an entry with the shot number
        shotPath[entityName] = {}
        print "\n" + entityName
        for fileType, versions in fileTypes.items():
            #store the name of the file without extension as well as the directory name
            rootFrame = versions[0]['path'][
                'local_path'][:versions[0]['path']['local_path'].find('%04d')]
            rootDir = rootFrame[:rootFrame.rfind("/")]
            #if the first frame is chosen for contactsheet
            if shotFrame == 'mid':
                #take the cut_in frame from shotgun data
                frame = str(
                    int((versions[0]['entity.Shot.sg_cut_in'] +
                         versions[0]['entity.Shot.sg_cut_out']) /
                        2)).zfill(4) + '.exr'
                tmpFullFile = rootFrame + frame
                #check if the frame exist if not go in the directory and chose the closest frame to the chosen frame in the directory
                fullFile = isFrameGood(fileIn=tmpFullFile,
                                       dirIn=rootDir)["filePath"]
                #put the chosen frame in the dictionary to be chosen as a contactsheet frame
                shotPath[entityName]['frame'] = fullFile
            elif shotFrame == 'end':
                frame = str(
                    versions[0]['entity.Shot.sg_cut_out']).zfill(4) + '.exr'
                tmpFullFile = rootFrame + frame
                #check if the frame exist if not go in the directory and chose the closest frame to the chosen frame in the directory
                fullFile = isFrameGood(fileIn=tmpFullFile,
                                       dirIn=rootDir)["filePath"]
                #put the chosen frame in the dictionary to be chosen as a contactsheet frame
                shotPath[entityName]['frame'] = fullFile
            else:
                frame = str(
                    versions[0]['entity.Shot.sg_cut_in']).zfill(4) + '.exr'
                tmpFullFile = rootFrame + frame
                #check if the frame exist if not go in the directory and chose the closest frame to the chosen frame in the directory
                fullFile = isFrameGood(fileIn=tmpFullFile,
                                       dirIn=rootDir)["filePath"]
                #put the chosen frame in the dictionary to be chosen as a contactsheet frame
                shotPath[entityName]['frame'] = fullFile

            shotPath[entityName]['allFrames'] = versions[0]['path'][
                'local_path'][:versions[0]['path']['local_path'].
                              find('%04d')] + """####.exr"""
            shotPath[entityName]['rootFrame'] = rootFrame
            shotPath[entityName]['version'] = str(
                versions[0]['version_number'])
            shotPath[entityName]['task'] = versions[0]['task']['name']

            #use the cut_in from shotgun or if the corresponding frame doesn't exist use the closest number
            cut_in = versions[0]['entity.Shot.sg_cut_in']
            checkFrame = shotPath[entityName]['rootFrame'] + str(cut_in).zfill(
                4) + ".exr"
            NewcutIn = isFrameGood(fileIn=checkFrame,
                                   dirIn=rootDir)["frameNumber"]
            shotPath[entityName]['in'] = NewcutIn

            #find the cut_out from shotgun or if the corresponding frame doesn't exist use the closest number
            cut_out = versions[0]['entity.Shot.sg_cut_out']
            checkFrame = shotPath[entityName]['rootFrame'] + str(
                cut_out).zfill(4) + ".exr"
            NewcutOut = isFrameGood(fileIn=checkFrame,
                                    dirIn=rootDir)["frameNumber"]
            shotPath[entityName]['out'] = NewcutOut

            #determine the mid point of the shot or if the corresponding frame doesn't exist use the closest number
            cut_mid = int((versions[0]['entity.Shot.sg_cut_in'] +
                           versions[0]['entity.Shot.sg_cut_out']) / 2)
            checkFrame = shotPath[entityName]['rootFrame'] + str(
                cut_mid).zfill(4) + ".exr"
            NewcutMid = isFrameGood(fileIn=checkFrame,
                                    dirIn=rootDir)["frameNumber"]
            shotPath[entityName]['mid'] = NewcutMid

            shotPath[entityName]['averageFrame'] = [
                NewcutIn, NewcutMid, NewcutOut
            ]
            print shotPath[entityName]['averageFrame']

    #number of shot in sequence
    nbShot = len(shotPath.keys())
    #height of contact sheet
    heightContactSheet = (int(nbShot / nbColumns) + 1) * 1170
    #width of contactsheet
    widthContactSheet = 1920 * nbColumns
    #average color for the shot
    averageColor = []
    #average color for sequence
    totalAvColor = [0.0, 0.0, 0.0, 1]
    # X/Y pos for nodes
    Xpos = 0
    Ypos = 0
    # size of the color swath in the roto node
    sizeSquare = widthContactSheet / nbShot
    if sizeSquare > 500:
        sizeSquare = 500
    # shift for the color swatch
    shiftX = 0
    # input of the contactsheet
    input = 0

    #creation of the roto Node
    rotoNode = nuke.nodes.Roto(name='roto', cliptype="no clip")
    rCurves = rotoNode['curves']
    root = rCurves.rootLayer

    #creation of the contactsheet node
    contactSheetNode = nuke.nodes.ContactSheet(name="contactSheet",
                                               rows=int(nbShot / nbColumns) +
                                               1,
                                               columns=nbColumns,
                                               roworder="TopBottom",
                                               width=widthContactSheet,
                                               height=heightContactSheet,
                                               center=True,
                                               gap=50)
    #reformat node for the contact sheet
    reformatGlobalNode = nuke.nodes.Reformat(type="to box",
                                             box_fixed=True,
                                             resize="none",
                                             box_width=widthContactSheet,
                                             box_height=heightContactSheet +
                                             2160,
                                             black_outside=True,
                                             name="reformatGlobal")
    #text node displaying the sequence number
    textSeqNode = nuke.nodes.Text2(message=seq,
                                   cliptype="no clip",
                                   global_font_scale=8.5,
                                   name="title" + seq)
    textSeqNode["box"].setValue([0, 0, 2500, 1080])
    textSeqNode["font"].setValue('Captain Underpants', 'Regular')
    textSeqNodeTransform = nuke.nodes.Transform(name="transformSeq_" + seq)
    textSeqNodeTransform['translate'].setValue([200, heightContactSheet + 900])
    textSeqNodeTransform.setInput(0, textSeqNode)
    #reformat for the roto node the height is the height of a swatch node
    reformatColAverage = nuke.nodes.Reformat(type="to box",
                                             box_fixed=True,
                                             resize="none",
                                             box_width=widthContactSheet,
                                             box_height=sizeSquare,
                                             center=False,
                                             pbb=True,
                                             name="reformatColAverage")
    #constant color for average sequence color
    constantNode = nuke.nodes.Constant(name="averageSeqColor")
    constantNodeTransform = nuke.nodes.Transform(name="transformConst_" + seq,
                                                 scale=0.6)
    constantNodeTransform['translate'].setValue(
        [widthContactSheet - (1920 * 2), heightContactSheet + 1200])
    constantNodeTransform.setInput(0, constantNode)
    #import of the colorChart
    readColorChartNode = nuke.nodes.Read(
        file=
        "/s/prods/captain/_sandbox/duda/images/sRGBtoSpi_ColorCheckerMikrosWrongColor.exr",
        name=seq + "_colorChart")
    readColorChartNodeTransform = nuke.nodes.Transform(name="transformChart_" +
                                                       seq,
                                                       scale=0.85)
    readColorChartNodeTransform['translate'].setValue(
        [widthContactSheet - (1920), heightContactSheet + 1080])
    readColorChartNodeTransform.setInput(0, readColorChartNode)

    #merge of all the nodes
    mergeNode = nuke.nodes.Merge2(
        inputs=[reformatGlobalNode, textSeqNodeTransform], name="merge_" + seq)
    mergeNode.setInput(3, readColorChartNodeTransform)
    mergeNode.setInput(4, reformatColAverage)
    mergeNode.setInput(5, constantNodeTransform)

    #write node
    writeFullNode = nuke.nodes.Write(name=seq + "Write",
                                     colorspace="linear",
                                     file_type="exr",
                                     file=fileOutPath["EXR"])
    writeFullLutBurnNode = nuke.nodes.Write(name=seq + "WriteLutBurn",
                                            colorspace="linear",
                                            file_type="jpeg",
                                            _jpeg_sub_sampling="4:2:2",
                                            file=fileOutPath["JPG"])
    writeFullLutBurnNode['_jpeg_quality'].setValue(0.75)
    writeHDNode = nuke.nodes.Write(name=seq + "WriteHD",
                                   colorspace="linear",
                                   file_type="jpeg",
                                   _jpeg_sub_sampling="4:2:2",
                                   file=fileOutPath["HD"])
    writeHDNode['_jpeg_quality'].setValue(0.75)
    writeMovieNode = nuke.nodes.Write(name=seq + "WriteMovie",
                                      colorspace="linear",
                                      file_type="mov",
                                      file=fileOutPath["Movie"])
    colorConvertNode = a = nuke.nodes.OCIOColorSpace(in_colorspace="linear",
                                                     out_colorspace="vd")
    reformatWriteHDNode = nuke.nodes.Reformat(type="to format",
                                              resize="fit",
                                              center=True,
                                              black_outside=True,
                                              name="reformatHD_" + seq)
    writeFullLutBurnNode.setInput(0, colorConvertNode)
    writeMovieNode.setInput(0, reformatWriteHDNode)
    colorConvertNode.setInput(0, mergeNode)
    writeFullNode.setInput(0, mergeNode)
    reformatWriteHDNode.setInput(0, colorConvertNode)
    writeHDNode.setInput(0, reformatWriteHDNode)

    for path in sorted(shotPath.keys()):
        frameNumber = []
        cutIn, cutOut, cutMid = shotPath[path]['in'], shotPath[path][
            'out'], shotPath[path]['mid']
        frameNumber = shotPath[path]['averageFrame']
        #get the average color for the shot
        averageColor = getAvrageColor(frameNumber=frameNumber,
                                      frame=shotPath[path]['rootFrame'])
        totalAvColor[0] += averageColor[0]
        totalAvColor[1] += averageColor[1]
        totalAvColor[2] += averageColor[2]
        readNode = nuke.nodes.Read(file=shotPath[path]['frame'],
                                   first=cutIn,
                                   last=cutOut,
                                   name="read_" + path)
        readNode.setXYpos(Xpos, Ypos)
        width = readNode.metadata("input/width")

        shape = rp.Shape(rCurves, type='bezier')
        shape.append([shiftX, sizeSquare])
        shape.append([shiftX + sizeSquare, sizeSquare])
        shape.append([shiftX + sizeSquare, 0])
        shape.append([shiftX, 0])
        shape.name = 'shape_' + path
        shapeAttr = shape.getAttributes()
        shapeAttr.set('r', averageColor[0])
        shapeAttr.set('g', averageColor[1])
        shapeAttr.set('b', averageColor[2])
        root.append(shape)

        reformatNode = nuke.nodes.Reformat(type="to box",
                                           box_fixed=True,
                                           resize="none",
                                           box_width=1920,
                                           box_height=1170,
                                           black_outside=True,
                                           name="reformat_" + path)
        reformatNode.setInput(0, readNode)
        reformatNode.setXYpos(Xpos, Ypos + 90)
        transformNode = nuke.nodes.Transform(name="transform_" + path)
        transformNode['translate'].setValue([0, -45])
        transformNode.setXYpos(Xpos, Ypos + 120)
        transformNode.setInput(0, reformatNode)
        textNode = nuke.nodes.Text2(message=path + "    Task: " +
                                    shotPath[path]['task'] + "    Version: " +
                                    shotPath[path]['version'],
                                    cliptype="no clip",
                                    global_font_scale=.8,
                                    name="title" + path)
        textNode["box"].setValue([25, 1050, 1920, 1160])
        textNode["font"].setValue('Captain Underpants', 'Regular')
        textNode.setInput(0, transformNode)
        textNode.setXYpos(Xpos, Ypos + 150)
        contactSheetNode.setInput(input, textNode)
        input += 1
        Xpos += 125
        shiftX += sizeSquare

    #set the average color for the sequence in the constant node
    avCol = [
        totalAvColor[0] / nbShot, totalAvColor[1] / nbShot,
        totalAvColor[2] / nbShot, 1
    ]
    constantNode['color'].setValue(avCol)

    #connection and position of the nodes for the comp
    centerX = Xpos / 2
    reformatGlobalNode.setInput(0, contactSheetNode)
    contactSheetNode.setXYpos(centerX, 700)
    reformatColAverage.setInput(0, rotoNode)
    reformatColAverage.setXYpos((centerX) - 200, 800)
    rotoNode.setXYpos((centerX) - 200, 750)
    reformatGlobalNode.setXYpos(centerX, 750)
    textSeqNode.setXYpos((centerX) + 200, 750)
    textSeqNodeTransform.setXYpos((centerX) + 200, 800)
    readColorChartNode.setXYpos((centerX) + 400, 700)
    readColorChartNodeTransform.setXYpos((centerX) + 400, 800)
    constantNode.setXYpos(centerX + 600, 700)
    constantNodeTransform.setXYpos((centerX) + 600, 800)
    mergeNode.setXYpos(centerX, 850)
    colorConvertNode.setXYpos(centerX + 200, 950)
    writeFullNode.setXYpos(centerX, 1050)
    writeFullLutBurnNode.setXYpos(centerX + 200, 1050)
    reformatWriteHDNode.setXYpos(centerX + 400, 1000)
    writeHDNode.setXYpos(centerX + 400, 1050)
    writeMovieNode.setXYpos(centerX + 600, 1050)


#createContactSheet('mid',nbColumns = 6,seq ="s0300",taskname='compo_precomp')
Example #3
0
def createContactSheetAllSequence(shotFrame='start',
                                  nbColumns=6,
                                  seq="s0300",
                                  taskname='compo_precomp',
                                  lightOnly=False,
                                  render=True,
                                  display=False):
    import nuke
    import nuke.rotopaint as rp
    root = nuke.root()
    root['format'].setValue('HD_1080')

    #find the shot with exr file(part of lighting step)
    res = findShots(selecFilter=exrFilter, seq=seq, taskname=taskname)

    #if user just want to see the anim in the contact sheet
    if not lightOnly:
        lightingShotFound = []
        for shot in res.keys():
            lightingShotFound.append(shot)
        resAnim = findShots(selecFilter=animFilter,
                            seq=seq,
                            taskname='anim_main',
                            shotList=lightingShotFound)
        resAnim.update(res)
        res = resAnim

    #create the main dict
    shotPath = createShotPathDict(res=res, shotFrame=shotFrame)

    #find the directory where to put the output files
    fileOutPath = createFileOutput(path=_OUTPATH_, seq=seq)

    #number of shot in exr for averaging color
    exrShot = 0
    for shot in res:
        exrShot += 1
    #number of shot in sequence
    nbShot = len(shotPath.keys())
    #height of contact sheet
    heightContactSheet = (int(nbShot / nbColumns) + 1) * 1170
    #width of contactsheet
    widthContactSheet = 1920 * nbColumns
    #average color for the shot
    averageColor = []
    #average color for sequence
    totalAvColor = [0.0, 0.0, 0.0, 1]
    # X/Y pos for nodes
    Xpos = 0
    Ypos = 0
    # size of the color swath in the roto node
    sizeSquare = widthContactSheet / nbShot
    if sizeSquare > 500:
        sizeSquare = 500
    # shift for the color swatch
    shiftX = 0
    # input of the contactsheet
    input = 0

    #creation of the roto Node
    rotoNode = nuke.nodes.Roto(name='roto', cliptype="no clip")
    rCurves = rotoNode['curves']
    root = rCurves.rootLayer

    #creation of the contactsheet node
    contactSheetNode = nuke.nodes.ContactSheet(name="contactSheet",
                                               rows=int(nbShot / nbColumns) +
                                               1,
                                               columns=nbColumns,
                                               roworder="TopBottom",
                                               width=widthContactSheet,
                                               height=heightContactSheet,
                                               center=True,
                                               gap=50)
    #reformat node for the contact sheet
    reformatGlobalNode = nuke.nodes.Reformat(type="to box",
                                             box_fixed=True,
                                             resize="none",
                                             box_width=widthContactSheet,
                                             box_height=heightContactSheet +
                                             2160,
                                             black_outside=True,
                                             name="reformatGlobal")
    #text node displaying the sequence number
    textSeqNode = nuke.nodes.Text2(message=seq,
                                   cliptype="no clip",
                                   global_font_scale=8.5,
                                   name="title" + seq)
    textSeqNode["box"].setValue([0, 0, 2500, 1080])
    textSeqNode["font"].setValue('Captain Underpants', 'Regular')
    textSeqNodeTransform = nuke.nodes.Transform(name="transformSeq_" + seq)
    textSeqNodeTransform['translate'].setValue([200, heightContactSheet + 900])
    textSeqNodeTransform.setInput(0, textSeqNode)
    #reformat for the roto node the height is the height of a swatch node
    reformatColAverage = nuke.nodes.Reformat(type="to box",
                                             box_fixed=True,
                                             resize="none",
                                             box_width=widthContactSheet,
                                             box_height=sizeSquare,
                                             center=False,
                                             pbb=True,
                                             name="reformatColAverage")
    #constant color for average sequence color
    constantNode = nuke.nodes.Constant(name="averageSeqColor")
    constantNodeTransform = nuke.nodes.Transform(name="transformConst_" + seq,
                                                 scale=0.6)
    constantNodeTransform['translate'].setValue(
        [widthContactSheet - (1920 * 2), heightContactSheet + 1200])
    constantNodeTransform.setInput(0, constantNode)
    #import of the colorChart
    readColorChartNode = nuke.nodes.Read(
        file=
        "/s/prods/captain/_sandbox/duda/images/sRGBtoSpi_ColorCheckerMikrosWrongColor.exr",
        name=seq + "_colorChart")
    readColorChartNodeTransform = nuke.nodes.Transform(name="transformChart_" +
                                                       seq,
                                                       scale=0.85)
    readColorChartNodeTransform['translate'].setValue(
        [widthContactSheet - (1920), heightContactSheet + 1080])
    readColorChartNodeTransform.setInput(0, readColorChartNode)

    #merge of all the nodes
    mergeNode = nuke.nodes.Merge2(
        inputs=[reformatGlobalNode, textSeqNodeTransform], name="merge_" + seq)
    mergeNode.setInput(3, readColorChartNodeTransform)
    mergeNode.setInput(4, reformatColAverage)
    mergeNode.setInput(5, constantNodeTransform)

    #write node
    writeFullNode = nuke.nodes.Write(name=seq + "Write",
                                     colorspace="linear",
                                     file_type="exr",
                                     file=fileOutPath["EXR"])
    writeFullLutBurnNode = nuke.nodes.Write(name=seq + "WriteLutBurn",
                                            colorspace="linear",
                                            file_type="jpeg",
                                            _jpeg_sub_sampling="4:2:2",
                                            file=fileOutPath["JPG"])
    writeFullLutBurnNode['_jpeg_quality'].setValue(0.75)
    writeHDNode = nuke.nodes.Write(name=seq + "WriteHD",
                                   colorspace="linear",
                                   file_type="jpeg",
                                   _jpeg_sub_sampling="4:2:2",
                                   file=fileOutPath["HD"])
    writeHDNode['_jpeg_quality'].setValue(0.75)
    writeMovieNode = nuke.nodes.Write(name=seq + "WriteMovie",
                                      colorspace="linear",
                                      file_type="mov",
                                      file=fileOutPath["Movie"])
    colorConvertNode = a = nuke.nodes.OCIOColorSpace(in_colorspace="linear",
                                                     out_colorspace="vd")
    reformatWriteHDNode = nuke.nodes.Reformat(type="to format",
                                              resize="fit",
                                              center=True,
                                              black_outside=True,
                                              name="reformatHD_" + seq)
    writeFullLutBurnNode.setInput(0, colorConvertNode)
    writeMovieNode.setInput(0, reformatWriteHDNode)
    colorConvertNode.setInput(0, mergeNode)
    writeFullNode.setInput(0, mergeNode)
    reformatWriteHDNode.setInput(0, colorConvertNode)
    writeHDNode.setInput(0, reformatWriteHDNode)

    for path in sorted(shotPath.keys()):
        frameNumber = []
        cutIn, cutOut, cutMid = shotPath[path]['in'], shotPath[path][
            'out'], shotPath[path]['mid']
        frameNumber = shotPath[path]['averageFrame']
        textColor = [1, 1, 1, 1]
        #get the average color for the shot for the exr image
        if shotPath[path]['imageFormat'] == '.exr':
            averageColor = getAvrageColor(frameNumber=frameNumber,
                                          frame=shotPath[path]['rootFrame'])
            totalAvColor[0] += averageColor[0]
            totalAvColor[1] += averageColor[1]
            totalAvColor[2] += averageColor[2]
        #else if it's coming from anim_main just put black
        else:
            averageColor = [0, 0, 0]
        readNode = nuke.nodes.Read(file=shotPath[path]['frame'],
                                   first=cutIn,
                                   last=cutOut,
                                   name="read_" + path)
        readNode.setXYpos(Xpos, Ypos)
        width = readNode.metadata("input/width")

        shape = rp.Shape(rCurves, type='bezier')
        shape.append([shiftX, sizeSquare])
        shape.append([shiftX + sizeSquare, sizeSquare])
        shape.append([shiftX + sizeSquare, 0])
        shape.append([shiftX, 0])
        shape.name = 'shape_' + path
        shapeAttr = shape.getAttributes()
        shapeAttr.set('r', averageColor[0])
        shapeAttr.set('g', averageColor[1])
        shapeAttr.set('b', averageColor[2])
        root.append(shape)

        reformatNode = nuke.nodes.Reformat(type="to box",
                                           box_fixed=True,
                                           resize="none",
                                           box_width=1920,
                                           box_height=1170,
                                           black_outside=True,
                                           name="reformat_" + path)
        reformatNode.setInput(0, readNode)
        reformatNode.setXYpos(Xpos, Ypos + 90)
        transformNode = nuke.nodes.Transform(name="transform_" + path)
        transformNode['translate'].setValue([0, -45])
        transformNode.setXYpos(Xpos, Ypos + 120)
        transformNode.setInput(0, reformatNode)
        if shotPath[path]['imageFormat'] == '.exr':
            if shotPath[path]['status'] == 'cmpt':
                textColor = [0, 1, 0, 1]
        textNode = nuke.nodes.Text2(message=path + "    Task: " +
                                    shotPath[path]['task'] + "    Version: " +
                                    shotPath[path]['version'],
                                    cliptype="no clip",
                                    global_font_scale=.8,
                                    name="title" + path)
        textNode["box"].setValue([25, 1050, 1920, 1160])
        textNode['color'].setValue(textColor)
        textNode["font"].setValue('Captain Underpants', 'Regular')
        textNode.setInput(0, transformNode)
        textNode.setXYpos(Xpos, Ypos + 150)
        contactSheetNode.setInput(input, textNode)
        input += 1
        Xpos += 125
        shiftX += sizeSquare

    #set the average color for the sequence in the constant node
    avCol = [
        totalAvColor[0] / exrShot, totalAvColor[1] / exrShot,
        totalAvColor[2] / exrShot, 1
    ]
    constantNode['color'].setValue(avCol)

    #connection and position of the nodes for the comp
    centerX = Xpos / 2
    reformatGlobalNode.setInput(0, contactSheetNode)
    contactSheetNode.setXYpos(centerX, 700)
    reformatColAverage.setInput(0, rotoNode)
    reformatColAverage.setXYpos((centerX) - 200, 800)
    rotoNode.setXYpos((centerX) - 200, 750)
    reformatGlobalNode.setXYpos(centerX, 750)
    textSeqNode.setXYpos((centerX) + 200, 750)
    textSeqNodeTransform.setXYpos((centerX) + 200, 800)
    readColorChartNode.setXYpos((centerX) + 400, 700)
    readColorChartNodeTransform.setXYpos((centerX) + 400, 800)
    constantNode.setXYpos(centerX + 600, 700)
    constantNodeTransform.setXYpos((centerX) + 600, 800)
    mergeNode.setXYpos(centerX, 850)
    colorConvertNode.setXYpos(centerX + 200, 950)
    writeFullNode.setXYpos(centerX, 1050)
    writeFullLutBurnNode.setXYpos(centerX + 200, 1050)
    reformatWriteHDNode.setXYpos(centerX + 400, 1000)
    writeHDNode.setXYpos(centerX + 400, 1050)
    writeMovieNode.setXYpos(centerX + 600, 1050)

    #render the frame
    if render:
        nuke.execute(writeFullNode, 1, 1)
        nuke.execute(writeFullLutBurnNode, 1, 1)
        nuke.execute(writeHDNode, 1, 1)

    if display:
        commandLine = "rv " + fileOutPath["JPG"]
        os.system(commandLine)
Example #4
0
def createMaster(Xpos=0,
                 Ypos=0,
                 shotPath={},
                 masterShot='',
                 nbColumns=6,
                 seq='s0300',
                 render=True,
                 display=False):
    import nuke
    import nuke.rotopaint as rp
    seqNumber = seq[:seq.find("_k")]
    fileOutPath = createFileOutput(path=_OUTPATH_,
                                   seq=seqNumber,
                                   masterName=seq,
                                   createMasterDir=True)
    previousXpos = Xpos
    masterTitleNode = None
    #number of shot in sequence
    nbShot = len(shotPath.keys())
    #height of contact sheet
    heightContactSheet = (int((nbShot) / nbColumns) + 1) * 1170
    if heightContactSheet == 0:
        heightContactSheet = 1170
    #width of contactsheet
    widthContactSheet = 1920 * nbColumns
    #average color for the shot
    averageColor = []
    #average color for sequence
    totalAvColor = [0.0, 0.0, 0.0, 1]
    # size of the color swath in the roto node
    sizeSquare = widthContactSheet / nbShot
    if sizeSquare > 500:
        sizeSquare = 500
    # shift for the color swatch
    shiftX = 0
    # input of the contactsheet
    input = 0

    #creation of the roto Node
    rotoNode = nuke.nodes.Roto(name='roto_' + seq, cliptype="no clip")
    rCurves = rotoNode['curves']
    root = rCurves.rootLayer

    #creation of the contactsheet node
    nbRows = int((nbShot - 1) / nbColumns) + 1 if int(
        (nbShot - 1) / nbColumns) > 0 else 1
    contactSheetNode = nuke.nodes.ContactSheet(name="contactSheet",
                                               rows=nbRows,
                                               columns=nbColumns,
                                               roworder="TopBottom",
                                               width=widthContactSheet,
                                               height=heightContactSheet,
                                               center=True,
                                               gap=50)
    transformContactSheet = nuke.nodes.Transform(name="transformContactSheet" +
                                                 seq)
    transformContactSheet['translate'].setValue([0, 1080 / 2])
    transformContactSheet.setInput(0, contactSheetNode)
    #reformat node for the contact sheet
    #reformatGlobalNode = nuke.nodes.Reformat(type = "to box",box_fixed = True,resize = "none",box_width = widthContactSheet, box_height = heightContactSheet+(2160*2),black_outside = True,name = "reformatGlobal")
    #text node displaying the sequence number
    textSeqNode = nuke.nodes.Text2(message=seq,
                                   cliptype="no clip",
                                   global_font_scale=8.5,
                                   name="title" + seq)
    textSeqNode["box"].setValue([0, 0, 5000, 1080])
    textSeqNode["font"].setValue('Captain Underpants', 'Regular')
    textSeqNodeTransform = nuke.nodes.Transform(name="transformSeq_" + seq)
    textSeqNodeTransform['translate'].setValue(
        [200, heightContactSheet + 900 + (2 * 1080)])
    textSeqNodeTransform.setInput(0, textSeqNode)
    #reformat for the roto node the height is the height of a swatch node
    reformatColAverage = nuke.nodes.Reformat(type="to box",
                                             box_fixed=True,
                                             resize="none",
                                             box_width=widthContactSheet,
                                             box_height=sizeSquare,
                                             center=False,
                                             pbb=True,
                                             name="reformatColAverage")
    #constant color for average sequence color
    constantNode = nuke.nodes.Constant(name="averageSeqColor")
    constantNodeTransform = nuke.nodes.Transform(name="transformConst_" + seq,
                                                 scale=0.6)
    constantNodeTransform['translate'].setValue([
        widthContactSheet - (1920 * 2), heightContactSheet + 1200 + (2 * 1080)
    ])
    constantNodeTransform.setInput(0, constantNode)
    #constant blackbg
    constantNodeBg = nuke.nodes.Constant(name="BG_" + seq)
    reformatNodeBg = nuke.nodes.Reformat(type="to box",
                                         box_fixed=True,
                                         resize="none",
                                         box_width=widthContactSheet,
                                         box_height=heightContactSheet +
                                         (2160 * 2),
                                         black_outside=True,
                                         name="reformatBg_" + seq)
    reformatNodeBg.setInput(0, constantNodeBg)
    #import of the colorChart
    readColorChartNode = nuke.nodes.Read(
        file=
        "/s/prods/captain/_sandbox/duda/images/sRGBtoSpi_ColorCheckerMikrosWrongColor.exr",
        name=seq + "_colorChart")
    readColorChartNodeTransform = nuke.nodes.Transform(name="transformChart_" +
                                                       seq,
                                                       scale=0.85)
    readColorChartNodeTransform['translate'].setValue(
        [widthContactSheet - (1920), heightContactSheet + 1080 + (2 * 1080)])
    readColorChartNodeTransform.setInput(0, readColorChartNode)
    #create the reformatNode for the masterShot
    reformatMasterShot = nuke.nodes.Reformat(type="to box",
                                             box_fixed=True,
                                             resize="fit",
                                             box_width=1920 * 2,
                                             box_height=1170 * 2,
                                             center=True,
                                             pbb=True,
                                             name="reformatMasterShot_" + seq)
    transformMasterShot = nuke.nodes.Transform(name="transformMasterShot_" +
                                               seq)
    transformMasterShot['center'].setValue([1920, 1080])
    transformMasterShot['translate'].setValue([(widthContactSheet / 2) - 1920,
                                               heightContactSheet + 800])
    transformMasterShot.setInput(0, reformatMasterShot)

    #merge of all the nodes
    mergeNode = nuke.nodes.Merge2(
        inputs=[reformatNodeBg, textSeqNodeTransform], name="merge_" + seq)
    mergeNode.setInput(3, readColorChartNodeTransform)
    mergeNode.setInput(4, reformatColAverage)
    mergeNode.setInput(5, constantNodeTransform)
    mergeNode.setInput(6, transformMasterShot)
    mergeNode.setInput(7, transformContactSheet)

    #write node
    writeFullNode = nuke.nodes.Write(name=seq + "Write",
                                     colorspace="linear",
                                     file_type="exr",
                                     file=fileOutPath["EXR"])
    writeFullLutBurnNode = nuke.nodes.Write(name=seq + "WriteLutBurn",
                                            colorspace="linear",
                                            file_type="jpeg",
                                            _jpeg_sub_sampling="4:2:2",
                                            file=fileOutPath["JPG"])
    writeFullLutBurnNode['_jpeg_quality'].setValue(0.75)
    writeHDNode = nuke.nodes.Write(name=seq + "WriteHD",
                                   colorspace="linear",
                                   file_type="jpeg",
                                   _jpeg_sub_sampling="4:2:2",
                                   file=fileOutPath["HD"])
    writeHDNode['_jpeg_quality'].setValue(0.75)
    writeMovieNode = nuke.nodes.Write(name=seq + "WriteMovie",
                                      colorspace="linear",
                                      file_type="mov",
                                      file=fileOutPath["Movie"])
    colorConvertNode = a = nuke.nodes.OCIOColorSpace(in_colorspace="linear",
                                                     out_colorspace="vd")
    reformatWriteHDNode = nuke.nodes.Reformat(type="to format",
                                              resize="fit",
                                              center=True,
                                              black_outside=True,
                                              name="reformatHD_" + seq)
    writeFullLutBurnNode.setInput(0, colorConvertNode)
    writeMovieNode.setInput(0, reformatWriteHDNode)
    colorConvertNode.setInput(0, mergeNode)
    writeFullNode.setInput(0, mergeNode)
    reformatWriteHDNode.setInput(0, colorConvertNode)
    writeHDNode.setInput(0, reformatWriteHDNode)

    for path in sorted(shotPath.keys()):
        cutIn, cutOut, cutMid = shotPath[path]['in'], shotPath[path][
            'out'], shotPath[path]['mid']
        frameNumber = shotPath[path]['averageFrame']
        textColor = [1, 1, 1, 1]
        #get the average color for the shot for the exr image
        if shotPath[path]['imageFormat'] == '.exr':
            averageColor = getAvrageColor(frameNumber=frameNumber,
                                          frame=shotPath[path]['rootFrame'])
            totalAvColor[0] += averageColor[0]
            totalAvColor[1] += averageColor[1]
            totalAvColor[2] += averageColor[2]
        #else if it's coming from anim_main just put black
        else:
            averageColor = [0, 0, 0]
        readNode = nuke.nodes.Read(file=shotPath[path]['frame'],
                                   first=cutIn,
                                   last=cutOut,
                                   name="read_" + path)
        readNode.setXYpos(Xpos, Ypos)

        #add a shape to the rotoNode
        shape = rp.Shape(rCurves, type='bezier')
        shape.append([shiftX, sizeSquare])
        shape.append([shiftX + sizeSquare, sizeSquare])
        shape.append([shiftX + sizeSquare, 0])
        shape.append([shiftX, 0])
        shape.name = 'shape_' + path
        shapeAttr = shape.getAttributes()
        shapeAttr.set('r', averageColor[0])
        shapeAttr.set('g', averageColor[1])
        shapeAttr.set('b', averageColor[2])
        root.append(shape)

        reformatNode = nuke.nodes.Reformat(type="to box",
                                           box_fixed=True,
                                           resize="none",
                                           box_width=1920,
                                           box_height=1170,
                                           black_outside=True,
                                           name="reformat_" + path)
        reformatNode.setInput(0, readNode)
        reformatNode.setXYpos(Xpos, Ypos + 90)
        transformNode = nuke.nodes.Transform(name="transform_" + path)
        transformNode['translate'].setValue([0, -45])
        transformNode.setXYpos(Xpos, Ypos + 120)
        transformNode.setInput(0, reformatNode)
        if shotPath[path]['imageFormat'] == '.exr':
            if shotPath[path]['status'] == 'cmpt':
                textColor = [0, 1, 0, 1]
        textNode = nuke.nodes.Text2(message=path + "    Task: " +
                                    shotPath[path]['task'] + "    Version: " +
                                    shotPath[path]['version'],
                                    cliptype="no clip",
                                    global_font_scale=.8,
                                    name="title" + path)
        textNode["box"].setValue([25, 1050, 1920, 1160])
        textNode['color'].setValue(textColor)
        textNode["font"].setValue('Captain Underpants', 'Regular')
        textNode.setInput(0, transformNode)
        textNode.setXYpos(Xpos, Ypos + 150)
        Xpos += 125
        if path == masterShot:
            masterTitleNode = nuke.toNode("title" + path)
        else:
            contactSheetNode.setInput(input, textNode)
            input += 1

        shiftX += sizeSquare

    #connect the masterShot to it's reformatNode
    reformatMasterShot.setInput(0, masterTitleNode)

    #set the average color for the sequence in the constant node
    avCol = [
        totalAvColor[0] / nbShot, totalAvColor[1] / nbShot,
        totalAvColor[2] / nbShot, 1
    ]
    constantNode['color'].setValue(avCol)

    #connection and position of the nodes for the comp
    centerX = (Xpos + previousXpos) / 2
    reformatMasterShot.setXYpos(previousXpos, 350)
    transformMasterShot.setXYpos(previousXpos, 400)
    #reformatGlobalNode.setInput(0,contactSheetNode)
    contactSheetNode.setXYpos(centerX, 700)
    reformatColAverage.setInput(0, rotoNode)
    reformatColAverage.setXYpos((centerX) - 200, 800)
    rotoNode.setXYpos((centerX) - 200, 750)
    constantNodeBg.setXYpos((centerX) - 400, 700)
    reformatNodeBg.setXYpos((centerX) - 400, 800)
    transformContactSheet.setXYpos(centerX, 750)
    textSeqNode.setXYpos((centerX) + 200, 750)
    textSeqNodeTransform.setXYpos((centerX) + 200, 800)
    readColorChartNode.setXYpos((centerX) + 400, 700)
    readColorChartNodeTransform.setXYpos((centerX) + 400, 800)
    constantNode.setXYpos(centerX + 600, 700)
    constantNodeTransform.setXYpos((centerX) + 600, 800)
    mergeNode.setXYpos(centerX, 850)
    colorConvertNode.setXYpos(centerX + 200, 950)
    writeFullNode.setXYpos(centerX, 1050)
    writeFullLutBurnNode.setXYpos(centerX + 200, 1050)
    reformatWriteHDNode.setXYpos(centerX + 400, 1000)
    writeHDNode.setXYpos(centerX + 400, 1050)
    writeMovieNode.setXYpos(centerX + 600, 1050)

    #render the frame
    if render:
        nuke.execute(writeFullNode, 1, 1)
        nuke.execute(writeFullLutBurnNode, 1, 1)
        nuke.execute(writeHDNode, 1, 1)

    if display:
        return fileOutPath["JPG"]
Example #5
0
def createContactSheetAllSequence(shotFrame = 'start',nbColumns = 6,seq ="s1300",taskname='compo_precomp',lightOnly = False, render=True,display = False, HDsplit=False,shotList=[],clampShot=True,useLightDNX=False):
    import nuke
    import nuke.rotopaint as rp
    rootNuke = nuke.root()
    rootNuke['format'].setValue( 'HD_1080' )
    rootNuke['first_frame'].setValue(_STARTCOMPFRAME_)
    rootNuke['last_frame'].setValue(1000)

    #find the shot with exr file(part of lighting step)
    res = createShotsInSeq(taskname=taskname, seq=seq,lightOnly = lightOnly,doMasters=False,shotList=shotList,clampShot=clampShot,useLightDNX=useLightDNX)

    #create the main dict
    shotPath= createShotPathDict(res=res,shotFrame=shotFrame)

    #find the directory where to put the output files
    fileOutPath = createFileOutput(path = _OUTPATH_, seq = seq)

    #number of shot in exr for averaging color
    exrShot = 0
    for shot in res:
        if shotPath[shot]['step'] == 'lighting':
            exrShot+=1
    #number of shot in sequence
    nbShot = len(shotPath.keys())
    #height of contact sheet
    heightContactSheet = (int(nbShot/nbColumns)+1)*1170
    #width of contactsheet
    widthContactSheet = 1920*nbColumns
    #average color for the shot
    averageColor=[]
    #average color for sequence
    totalAvColor=[0.0,0.0,0.0,1]
    # X/Y pos for nodes
    Xpos = 0
    Ypos = 0
    # size of the color swath in the roto node
    sizeSquare = widthContactSheet/nbShot
    if sizeSquare > 500:
        sizeSquare = 500
    # shift for the color swatch
    shiftX = 0
    # input of the contactsheet
    input = 0
    #max and min cut for the sequence
    maxCutOut = 0
    minCutIn = 101

    #variable for HD presentation (i.e contactSheet separated if nbShots > 30
    nbContactSheetHD = 0
    contactSheetHD= []
    nbRowHD=4
    nbColumnsHD = 6
    colTimeRow = nbColumnsHD * nbRowHD
    heightContactSheetHD = nbRowHD * 1170
    widthContactSheetHD = nbColumnsHD * 1920
    if nbShot > colTimeRow:
        nbContactSheetHD = float(nbShot)/float(colTimeRow)
        frac, whole = math.modf(nbContactSheetHD)
        if frac > 0:
            nbContactSheetHD = int(whole + 1)
        else:
            nbContactSheetHD= int(nbContactSheetHD)


    #creation of the roto Node
    rotoNode = nuke.nodes.Roto(name = 'roto',cliptype="no clip")
    rCurves = rotoNode['curves']
    root = rCurves.rootLayer

    #creation of the contactsheet node
    contactSheetNode = nuke.nodes.ContactSheet(name="contactSheet",rows=int(nbShot/nbColumns)+1,columns=nbColumns,roworder="TopBottom",width=widthContactSheet,height=heightContactSheet, center= True,gap = 50)

    #reformat node for the contact sheet
    reformatGlobalNode = nuke.nodes.Reformat(type = "to box",box_fixed = True,resize = "none",box_width = widthContactSheet, box_height = heightContactSheet+2160,black_outside = True,name = "reformatGlobal")
    #text node displaying the sequence number
    textSeqNode = nuke.nodes.Text2(message=seq,cliptype="no clip",global_font_scale=8.5,name="title"+seq)
    textSeqNode["box"].setValue([0,0,2500,1080])
    textSeqNode["font"].setValue('Captain Underpants', 'Regular')
    textSeqNodeTransform = nuke.nodes.Transform(name = "transformSeq_"+seq)
    textSeqNodeTransform['translate'].setValue([200,heightContactSheet+900])
    textSeqNodeTransform.setInput(0,textSeqNode)
    #reformat for the roto node the height is the height of a swatch node
    reformatColAverage = nuke.nodes.Reformat(type="to box",box_fixed=True,resize="none",box_width=widthContactSheet,box_height=sizeSquare,center=False,pbb=True,name="reformatColAverage")
    #constant color for average sequence color
    constantNode = nuke.nodes.Constant(name="averageSeqColor")
    constantNodeTransform = nuke.nodes.Transform(name = "transformConst_"+seq,scale = 0.6)
    constantNodeTransform['translate'].setValue([widthContactSheet-(1920*2),heightContactSheet+1200])
    constantNodeTransform.setInput(0,constantNode)
    #import of the colorChart
    readColorChartNode = nuke.nodes.Read(file="/s/prods/captain/_sandbox/duda/images/sRGBtoSpi_ColorCheckerMikrosWrongColor.exr",name=seq+"_colorChart")
    readColorChartNodeTransform = nuke.nodes.Transform(name = "transformChart_"+seq,scale = 0.85)
    readColorChartNodeTransform['translate'].setValue([widthContactSheet-(1920),heightContactSheet+1080])
    readColorChartNodeTransform.setInput(0,readColorChartNode)

    #merge of all the nodes
    mergeNode = nuke.nodes.Merge2(inputs=[reformatGlobalNode,textSeqNodeTransform],name="merge_"+seq)
    mergeNode.setInput(3,readColorChartNodeTransform)
    mergeNode.setInput(4,reformatColAverage)
    mergeNode.setInput(5,constantNodeTransform)

    #write node
    writeFullNode = nuke.nodes.Write(name = seq + "Write", colorspace = "linear", file_type = "exr",file =fileOutPath["EXR"] )
    writeFullLutBurnNode = nuke.nodes.Write(name = seq + "WriteLutBurn", colorspace = "linear", file_type = "jpeg", _jpeg_sub_sampling = "4:2:2",file =fileOutPath["JPG"])
    writeFullLutBurnNode['_jpeg_quality'].setValue(0.75)
    writeHDNode = nuke.nodes.Write(name = seq + "WriteHD", colorspace = "linear", file_type = "jpeg", _jpeg_sub_sampling = "4:2:2",file =fileOutPath["HD"])
    writeHDNode['_jpeg_quality'].setValue(0.75)
    writeMovieNode = nuke.nodes.Write(name = seq + "WriteMovie", colorspace = "linear", file_type = "mov",file =fileOutPath["Movie"])
    colorConvertNode = nuke.nodes.OCIOColorSpace(in_colorspace="linear",out_colorspace="vd")
    reformatWriteHDNode = nuke.nodes.Reformat(type="to format",resize="fit",center=True,black_outside = True,name="reformatHD_"+seq)
    writeFullLutBurnNode.setInput(0,colorConvertNode)
    writeMovieNode.setInput(0,reformatWriteHDNode)
    colorConvertNode.setInput(0,mergeNode)
    writeFullNode.setInput(0,mergeNode)
    reformatWriteHDNode.setInput(0,colorConvertNode)
    writeHDNode.setInput(0,reformatWriteHDNode)

    for path in sorted(shotPath.keys()):
        frameNumber =[]
        cutIn, cutOut, cutMid = shotPath[path]['in'], shotPath[path]['out'],shotPath[path]['mid']
        frameNumber = shotPath[path]['averageFrame']
        textColor = [0,0,0,1]
        if cutOut > maxCutOut:
            maxCutOut = cutOut
        if cutIn < minCutIn:
            minCutIn = cutIn
        #get the average color only for the shot with exr image
        #if shotPath[path]['imageFormat'] == '.exr':
        if shotPath[path]['step'] == 'lighting':
            averageColor =getAvrageColor(frameNumber=frameNumber, frame=shotPath[path]['inputFile'])
            totalAvColor[0]+=averageColor[0]
            totalAvColor[1]+=averageColor[1]
            totalAvColor[2]+=averageColor[2]
        #else if it's coming from anim_main just put black
        else:
            averageColor = [0,0,0]
        readNode = nuke.nodes.Read(file = shotPath[path]['inputFile'],first=cutIn,last=cutOut, name = "read_"+path,on_error ='nearestframe',after='loop')
        readNode.setXYpos(Xpos, Ypos)
        width = readNode.metadata("input/width")

        shape =rp.Shape(rCurves,type='bezier')
        shape.append([shiftX,sizeSquare])
        shape.append([shiftX + sizeSquare,sizeSquare])
        shape.append([shiftX + sizeSquare,0])
        shape.append([shiftX,0])
        shape.name = 'shape_'+path
        shapeAttr = shape.getAttributes()
        shapeAttr.set('r',averageColor[0])
        shapeAttr.set('g',averageColor[1])
        shapeAttr.set('b',averageColor[2])
        root.append(shape)

        frameHoldNode = nuke.nodes.FrameHold(name="frameHold_"+path,first_frame =shotPath[path]['frame'])
        frameHoldNode.setInput(0,readNode)
        frameHoldNode.setXYpos(Xpos,Ypos +90)
        reformatNode = nuke.nodes.Reformat(type = "to box",box_fixed = True,resize = "none",box_width = 1920, box_height = 1170,black_outside = True,name = "reformat_" + path)
        reformatNode.setInput(0,frameHoldNode)
        reformatNode.setXYpos(Xpos, Ypos +120)
        transformNode = nuke.nodes.Transform(name = "transform_"+path)
        transformNode['translate'].setValue([0,-45])
        transformNode.setXYpos(Xpos, Ypos +150)
        transformNode.setInput(0,reformatNode)
        if shotPath[path]['step'] == 'lighting':
            if shotPath[path]['status'] == 'cmpt':
                textColor = [0,1,0,1]
            else:
                textColor = [1,0,0,1]
        textNode = nuke.nodes.Text2(message=path + "    Task: " + shotPath[path]['task'] + "    Version: " + shotPath[path]['version']+'     Frame: '+ str(shotPath[path]['frame']),cliptype="no clip",global_font_scale=.6,name="title"+path)
        textNode["box"].setValue([25,1050,1920,1160])
        #textNode['color'].setValue(textColor)
        textNode["font"].setValue('Captain Underpants', 'Regular')
        textNode.setInput(0,transformNode)
        textNode.setXYpos(Xpos, Ypos +180)

        statusTextNode = nuke.nodes.Text2(message='g',cliptype="no clip",global_font_scale=.6,name="title"+path)
        statusTextNode["box"].setValue([1836.5,1091.5,1897.5,1152.5])
        statusTextNode['color'].setValue(textColor)
        statusTextNode["font"].setValue('Webdings', 'Regular')
        statusTextNode.setInput(0,textNode)
        statusTextNode.setXYpos(Xpos, Ypos +220)
        contactSheetNode.setInput(input,statusTextNode)
        input+=1
        Xpos += 125
        shiftX += sizeSquare

    #set the comp out frame
    #set the average color for the sequence in the constant node
    if exrShot is not 0:
        avCol = [totalAvColor[0]/exrShot,totalAvColor[1]/exrShot,totalAvColor[2]/exrShot,1]
        constantNode['color'].setValue(avCol)


    #if the user want multiple frames of contactSheet
    if HDsplit and nbShot > colTimeRow :
        inputContactSheet = 0
        contactSheetNumber = 0
        for i in range(nbContactSheetHD):
            contactSheetNodeHD = nuke.nodes.ContactSheet(name="contactSheet"+str(i),rows=nbRowHD,columns=nbColumnsHD,roworder="TopBottom",width=widthContactSheetHD,height=heightContactSheetHD, center= True,gap = 50)
            contactSheetNodeHD["hide_input"].setValue(True)
            contactSheetHD.append(contactSheetNodeHD )
        for item in sorted(shotPath.keys()):
            node = nuke.toNode('title'+item)
            contactSheetHD[contactSheetNumber].setInput(inputContactSheet,node)
            inputContactSheet += 1
            if inputContactSheet > colTimeRow:
                inputContactSheet = 0
                contactSheetNumber += 1
        appendClipNodeContactSheetHD = nuke.nodes.AppendClip(name = "appendClipNodeContactSheetHD_"+seq,firstFrame=_STARTCOMPFRAME_)
        inputContactSheet = 0
        for node in contactSheetHD:
            appendClipNodeContactSheetHD.setInput(inputContactSheet,node)
            inputContactSheet+=1

        readColorChartNodeTransformHD = nuke.nodes.Transform(name = "transformChartHD_"+seq,scale = 0.85)
        readColorChartNodeTransformHD['translate'].setValue([widthContactSheetHD-(1920),heightContactSheetHD+1080])
        readColorChartNodeTransformHD.setInput(0,readColorChartNode)

        textSeqNodeTransformHD = nuke.nodes.Transform(name = "transformSeqHD_"+seq)
        textSeqNodeTransformHD['translate'].setValue([200,heightContactSheetHD+900])
        textSeqNodeTransformHD.setInput(0,textSeqNode)

        constantNodeTransformHD = nuke.nodes.Transform(name = "transformConstHD_"+seq,scale = 0.6)
        constantNodeTransformHD['translate'].setValue([widthContactSheetHD-(1920*2),heightContactSheetHD+1200])
        constantNodeTransformHD.setInput(0,constantNode)

        reformatColAverageHD = nuke.nodes.Reformat(type="to box",box_fixed=True,resize="none",box_width=widthContactSheetHD,box_height=sizeSquare,center=False,pbb=True,name="reformatColAverageHD")
        reformatColAverageHD.setInput(0,rotoNode)

        reformatGlobalNodeHD = nuke.nodes.Reformat(type = "to box",box_fixed = True,resize = "none",box_width = widthContactSheetHD, box_height = heightContactSheetHD+2160,black_outside = True,name = "reformatGlobalHD")
        reformatGlobalNodeHD.setInput(0,appendClipNodeContactSheetHD)

        mergeNodeHD = nuke.nodes.Merge2(inputs=[reformatGlobalNodeHD,textSeqNodeTransformHD],name="merge_"+seq)
        mergeNodeHD.setInput(3,readColorChartNodeTransformHD)
        mergeNodeHD.setInput(4,reformatColAverageHD)
        mergeNodeHD.setInput(5,constantNodeTransformHD)
        #mergeNodeHD["hide_input"].setValue(True)

        pageNumberNodeHD = nuke.nodes.Text2(cliptype="no clip",global_font_scale=3,name="pageNumberHD_"+seq)
        pageNumberNodeHD.setInput(0,mergeNodeHD)
        pageNumberNodeHD["box"].setValue([9576,280,12345,890])
        pageNumberNodeHD["font"].setValue('Captain Underpants', 'Regular')
        pageNumberNodeHD["message"].setValue("Page: [python nuke.frame()-100]/"+str(nbContactSheetHD))

        colorConvertNodeHD = nuke.nodes.OCIOColorSpace(in_colorspace="linear",out_colorspace="vd")
        colorConvertNodeHD.setInput(0,pageNumberNodeHD)

        reformatWriteHDNodeHD = nuke.nodes.Reformat(type="to format",resize="fit",center=True,black_outside = True,name="reformatHD_"+seq)
        reformatWriteHDNodeHD.setInput(0,colorConvertNodeHD)
        writeHDNode = nuke.nodes.Write(name = seq + "WriteHD", colorspace = "linear", file_type = "mov",file =fileOutPath["HD"],mov64_codec='Avid DNxHD Codec',mov64_dnxhd_codec_profile='DNxHD 422 10-bit 220Mbit')
        writeHDNode.setInput(0,reformatWriteHDNodeHD)

        centerXHD = Xpos/2 -600
        shiftX = -125
        for item in contactSheetHD:
            newXPos = shiftX + abs(contactSheetHD.index(item)*shiftX)
            item.setXYpos(centerXHD+newXPos,700)
        appendClipNodeContactSheetHD.setXYpos(centerXHD,750)
        reformatColAverageHD.setXYpos(centerXHD-shiftX,750)
        reformatGlobalNodeHD.setXYpos(centerXHD,800)
        textSeqNodeTransformHD.setXYpos(centerXHD-shiftX,800)
        readColorChartNodeTransformHD.setXYpos(centerXHD+shiftX,800)
        mergeNodeHD.setXYpos(centerXHD,850)
        pageNumberNodeHD.setXYpos(centerXHD,900)
        colorConvertNodeHD.setXYpos(centerXHD,950)
        reformatWriteHDNodeHD.setXYpos(centerXHD,1000)
        writeHDNode.setXYpos(centerXHD,1050)

    #connection and position of the nodes for the comp
    centerX = Xpos/2
    reformatGlobalNode.setInput(0,contactSheetNode)
    contactSheetNode.setXYpos(centerX, 700)
    reformatColAverage.setInput(0,rotoNode)
    reformatColAverage.setXYpos((centerX)-200, 800)
    rotoNode.setXYpos((centerX)-200, 750)
    reformatGlobalNode.setXYpos(centerX, 750)
    textSeqNode.setXYpos((centerX)+200, 750)
    textSeqNodeTransform.setXYpos((centerX)+200, 800)
    readColorChartNode.setXYpos((centerX)+400, 700)
    readColorChartNodeTransform.setXYpos((centerX)+400, 800)
    constantNode.setXYpos(centerX+600, 700)
    constantNodeTransform.setXYpos((centerX)+600, 800)
    mergeNode.setXYpos(centerX, 850)
    colorConvertNode.setXYpos(centerX + 200, 950)
    writeFullNode.setXYpos(centerX, 1050)
    writeFullLutBurnNode.setXYpos(centerX + 200, 1050)
    reformatWriteHDNode.setXYpos(centerX + 400, 1000)
    if not HDsplit:
        writeHDNode.setXYpos(centerX + 400, 1050)
    writeMovieNode.setXYpos(centerX + 600, 1050)

    print type(maxCutOut)
    rootNuke['last_frame'].setValue(maxCutOut)

    #render the frame
    if render:
        nuke.execute(writeFullNode,1,1)
        nuke.execute(writeFullLutBurnNode,1,1)
        if not HDsplit or nbShot < colTimeRow:
            nuke.execute(writeHDNode,1,1)
        else:
            nuke.execute(writeHDNode,1,nbContactSheetHD)

    if display:
        HDpath = fileOutPath["HD"][:fileOutPath["HD"].find(".")]+'*'
        commandLine = "rv "+ HDpath
        os.system(commandLine)
# def main():
#     seq = 's1300'
#     res = createShotsInSeq(taskname='compo_precomp', seq=seq,lightOnly = False,doMasters=True)
#     shotPath = createShotPathDict(res = res,shotFrame = 'start')
#     #res = findShots(selecFilter=exrFilter,seq=seq,taskname=taskname)
#     #shotPath = createShotPathDict(res = res,shotFrame = 'start')
#
#     # shotList = []
#     # for key in shotPath:
#     #     shotList.append(key)
#     # status = findStatusTask(taskname = taskname,shotList = shotList,seq=seq)
#     # for key in shotPath:
#     #     shotPath[key]['status']= status[key]
#     pprint.pprint(shotPath)
#
# if __name__ == '__main__':
#     main()


#createContactSheetAllSequence('mid',nbColumns = 6,seq ="s1300",taskname='compo_precomp',lightOnly = False,HDsplit=False,render=False,shotList=[],clampShot=True,useLightDNX=False)