Nuke tmp

From Antoine Vienne | Wiki
Jump to navigation Jump to search

Maya tmp Scripts

Nuke - Extract some images from Read

nodes = nuke.selectedNodes()
for node in nodes:
    if node.Class() == 'Read':

        oPath = node['file'].value()
        first = node['first'].value()
        last = node['last'].value()
        oFrameHold = nuke.allNodes('FrameHold')

        channels = node.channels()
        layers = list( set('1234') )
        layers.sort()
        readPath = node['file'].evaluate()
        readPath = os.path.splitext(readPath)[0]
        print(readPath)
        if 'rgba' in layers:
            layers.remove('rgba')
        for n in layers:
            shuffleNode = nuke.nodes.FrameHold(inputs=[node])
            shuffleNode['first_frame'].setValue(last/2)

Nuke - Create STMaps nodes ands Write for selected Reads

for oReadNode in nuke.selectedNodes():

    oPath =  oReadNode['file'].value()
    first =  oReadNode['first'].value()
    last =  oReadNode['last'].value()
    newPath = oPath.split('/')[-1]
    oReadNode['selected'].setValue(True)

    STMap = nuke.createNode ("STMap")
    STMap.knob('channels').setValue('rgb')
    STMap.knob('uv').setValue('rgb')

    Write = nuke.createNode ("Write")   

    #Specify file path here
    osdir ='C:/YOUR_PATH'
    
    Write.knob('channels').setValue('rgb')
    Write.knob('colorspace').setValue('2')
    Write.knob('file').setValue(osdir+'/'+newPath)
    Write.knob('file_type').setValue('tiff')
    Write.knob('datatype').setValue('1')
    Write.knob('compression').setValue('2')
    Write.knob('use_limit').setValue(True)
    Write.knob('first').setValue(1)
    Write.knob('last').setValue(last-first+1)
    Write.knob('create_directories').setValue(True)