Exemple #1
0
def setFramesFromTimeCode( i_afnode):

    timecode = i_afnode.knob('timecode').value()

    if len(timecode) == 0:
        nuke.message('Timecode is empty.')
        return

    frange = cgruutils.timecodesToFrameRange( timecode, nuke.root().fps())
    if frange is None or frange[0] is None or frange[1] is None:
        nuke.message('Invalid timecode: "%s"' % timecode)
        return

    i_afnode.knob('framefirst').setValue( frange[0])
    i_afnode.knob('framelast').setValue( frange[1])
    i_afnode.knob('timecode').setValue( cgruutils.timecodesFromFrameRange( frange[0], frange[1]))
Exemple #2
0
def setFramesFromTimeCode( i_afnode):

    timecode = i_afnode.knob('timecode').value()

    if len(timecode) == 0:
        nuke.message('Timecode is empty.')
        return

    frange = cgruutils.timecodesToFrameRange( timecode, nuke.root().fps())
    if frange is None or frange[0] is None or frange[1] is None:
        nuke.message('Invalid timecode: "%s"' % timecode)
        return

    i_afnode.knob('framefirst').setValue( frange[0])
    i_afnode.knob('framelast').setValue( frange[1])
    i_afnode.knob('timecode').setValue( cgruutils.timecodesFromFrameRange( frange[0], frange[1]))
Exemple #3
0
    def __init__(self, afnode, wnode, subblock, prefix, fparams):
        if VERBOSE == 2:
            print('Initializing block parameters for "%s"' % wnode.name())
        self.wnode = wnode
        self.valid = True

        self.subblock = subblock
        self.prefix = prefix

        self.framefirst = nuke.root().firstFrame()
        self.framelast = nuke.root().lastFrame()
        self.frameinc = 1
        self.framespertask = 1
        self.framesequential = 1
        self.skipexisting = 0
        self.maxruntasks = -1
        self.capacity = -1
        self.maxperhost = -1
        self.maxruntime = -1
        self.hostsmask = None
        self.hostsmaskexclude = None
        self.fullrangedepend = 0
        self.tmpimage = 1
        self.pathsmap = 1
        self.imgfiles = []
        self.tickets_use = 0
        self.tickets_data = None

        # Just to add to the final job name some info, for example timecode
        self.jobname_suffix = ''

        if afnode is not None:
            self.framefirst = int(afnode.knob('framefirst').value())
            self.framelast = int(afnode.knob('framelast').value())
            self.frameinc = int(afnode.knob('frameinc').value())
            self.framespertask = int(afnode.knob('framespertask').value())
            self.framesequential = int(afnode.knob('framesequential').value())
            self.skipexisting = int(afnode.knob('skipexisting').value())
            self.maxruntasks = int(afnode.knob('maxruntasks').value())
            self.capacity = int(afnode.knob('capacity').value())
            self.maxperhost = int(afnode.knob('maxperhost').value())
            self.maxruntime = int(afnode.knob('maxruntime').value())
            self.tmpimage = int(afnode.knob('tmpimage').value())
            self.pathsmap = int(afnode.knob('pathsmap').value())
            self.hostsmask = afnode.knob('hostsmask').value()
            self.hostsmaskexclude = afnode.knob('hostsmaskexcl').value()
            self.tickets_use = int(afnode.knob('tickets_use').value())
            self.tickets_data = afnode.knob('tickets_data').value()

            if int(afnode.knob('timecode_use').value()):
                timecode = afnode.knob('timecode').value()
                if len(timecode):
                    frange = cgruutils.timecodesToFrameRange(
                        timecode,
                        nuke.root().fps())
                    if frange is None or frange[0] is None or frange[1] is None:
                        nuke.message('Invalid timecode: "%s"' % timecode)
                        return None
                    self.framefirst = frange[0]
                    self.framelast = frange[1]
                    afnode.knob('timecode').setValue(
                        cgruutils.timecodesFromFrameRange(
                            frange[0], frange[1]))

                    # Add timecode to a final job name:
                    self.jobname_suffix += '.' + timecode.replace(' ', '')

        if self.skipexisting: self.framespertask = 1

        self.writename = str(wnode.fullName())

        if wnode.Class() == RenderNodeClassName:
            afcommon = __import__('afcommon', globals(), locals(), [])
            # Get images files:
            if nuke.toNode('root').knob('proxy').value():
                fileknob = wnode.knob('proxy')
            else:
                fileknob = wnode.knob('file')

            # Get views:
            views = wnode.knob('views')
            if views is not None:
                views = views.value()
                if views is None or views == '':
                    views = nuke.views()
                else:
                    views = views.split(' ')
            else:
                views = nuke.views()

            # Iterate views:
            for view in views:
                view = view.strip()
                if not len(view):
                    continue  # skip empty view, may be after split(' ')

                # Check view exists:
                if not view in nuke.views():
                    print('Error: Skipping invalid view: "%s"' % view)
                    continue

                    # if len( self.imgfiles):
                # self.imgfiles += ';'

                # Get show files for current view and first and last frames:
                octx = nuke.OutputContext()
                octx.setView(1 + nuke.views().index(view))
                octx_framefirst = self.framefirst
                octx_framelast = self.framelast
                if octx_framefirst < 0:
                    octx_framefirst = 0
                if octx_framelast < 0:
                    octx_framelast = 0

                # If frame first and frame last are equal no sequence needed
                if octx_framefirst == octx_framelast:
                    octx.setFrame(octx_framefirst)
                    self.imgfiles.append(fileknob.getEvaluatedValue(octx))
                else:
                    # Get files from first and last frames
                    # to calculate frames pattern:
                    octx.setFrame(octx_framefirst)
                    images1 = fileknob.getEvaluatedValue(octx)
                    if images1 is None or images1 == '':
                        nuke.message('Error:\n'
                                     '%s\n'
                                     'Files are empty.\n'
                                     'View "%s", frame %d.' %
                                     (self.writename, view, self.framefirst))
                        self.valid = False
                        return
                    octx.setFrame(octx_framelast)
                    images2 = fileknob.getEvaluatedValue(octx)
                    if images2 is None or images2 == '':
                        nuke.message('Error:\n'
                                     '%s\n'
                                     'Files are empty.\n'
                                     'View "%s", frame %d.' %
                                     (self.writename, view, self.framelast))
                        self.valid = False
                        return
                    part1, padding, part2 = \
                        afcommon.splitPathsDifference(images1, images2)

                    if padding < 1:
                        nuke.message('Error:\n'
                                     '%s\n'
                                     'Invalid files pattern.\n'
                                     'View "%s".' % (self.writename, view))
                        self.valid = False
                        return
                    self.imgfiles.append('%s@%s@%s' %
                                         (part1, '#' * padding, part2))

            # Check images folders:
            for imgfile in self.imgfiles:
                folder = os.path.dirname(imgfile)
                if folder != '':
                    if not os.path.isdir(folder):
                        result = nuke.ask('Write Node "%s" Directory\n'
                                          '%s\n'
                                          'Does not exist.\n'
                                          'Create it?' %
                                          (self.writename, folder))
                        if result:
                            os.makedirs(folder)
                            if not os.path.isdir(folder):
                                nuke.message("Can't create folder:\n%s" %
                                             folder)
                                self.valid = False
                        else:
                            self.valid = False
        elif wnode.Class() == DailiesNodeClassName:
            if VERBOSE:
                print('Generating dailies "%s"' % self.writename)
        else:
            nuke.message('Node type\n"%s"\nis unsendable.' % self.writename)
            self.valid = False

        for par in fparams:
            if fparams[par] is not None:
                if hasattr(self, par):
                    setattr(self, par, fparams[par])

        self.name = self.writename
        if subblock:
            if self.prefix is not None:
                if self.prefix != '':
                    self.name = self.prefix + self.name

        self.dependmask = ''
        self.tasksdependmask = ''
Exemple #4
0
    def __init__(self, afnode, wnode, subblock, prefix, fparams):
        if VERBOSE == 2:
            print('Initializing block parameters for "%s"' % wnode.name())
        self.wnode = wnode
        self.valid = True

        self.subblock = subblock
        self.prefix = prefix

        self.framefirst = nuke.root().firstFrame()
        self.framelast = nuke.root().lastFrame()
        self.frameinc = 1
        self.framespertask = 1
        self.framesequential = 1
        self.skipexisting = 0
        self.maxhosts = -1
        self.capacity = -1
        self.maxperhost = -1
        self.maxruntime = -1
        self.hostsmask = None
        self.hostsmaskexclude = None
        self.fullrangedepend = 0
        self.tmpimage = 1
        self.pathsmap = 1
        self.imgfiles = []

        # Just to add to the final job name some info, for example timecode
        self.jobname_suffix = ''

        if afnode is not None:
            self.framefirst = int(afnode.knob('framefirst').value())
            self.framelast = int(afnode.knob('framelast').value())
            self.frameinc = int(afnode.knob('frameinc').value())
            self.framespertask = int(afnode.knob('framespertask').value())
            self.framesequential = int(afnode.knob('framesequential').value())
            self.skipexisting = int(afnode.knob('skipexisting').value())
            self.maxhosts = int(afnode.knob('maxhosts').value())
            self.capacity = int(afnode.knob('capacity').value())
            self.maxperhost = int(afnode.knob('maxperhost').value())
            self.maxruntime = int(afnode.knob('maxruntime').value())
            self.tmpimage = int(afnode.knob('tmpimage').value())
            self.pathsmap = int(afnode.knob('pathsmap').value())
            self.hostsmask = afnode.knob('hostsmask').value()
            self.hostsmaskexclude = afnode.knob('hostsmaskexcl').value()

            if int(afnode.knob('timecode_use').value()):
                timecode = afnode.knob('timecode').value()
                if len (timecode):
                    frange = cgruutils.timecodesToFrameRange( timecode, nuke.root().fps())
                    if frange is None or frange[0] is None or frange[1] is None:
                        nuke.message('Invalid timecode: "%s"' % timecode)
                        return None
                    self.framefirst = frange[0]
                    self.framelast  = frange[1]
                    afnode.knob('timecode').setValue( cgruutils.timecodesFromFrameRange( frange[0], frange[1]))

                    # Add timecode to a final job name:
                    self.jobname_suffix += '.' + timecode.replace(' ','')

        if self.skipexisting: self.framespertask = 1

        self.writename = str(wnode.fullName())

        if wnode.Class() == RenderNodeClassName:
            afcommon = __import__('afcommon', globals(), locals(), [])
            # Get images files:
            if nuke.toNode('root').knob('proxy').value():
                fileknob = wnode.knob('proxy')
            else:
                fileknob = wnode.knob('file')

            # Get views:
            views = wnode.knob('views')
            if views is not None:
                views = views.value()
                if views is None or views == '':
                    views = nuke.views()
                else:
                    views = views.split(' ')
            else:
                views = nuke.views()

            # Iterate views:
            for view in views:
                view = view.strip()
                if not len(view):
                    continue  # skip empty view, may be after split(' ')

                # Check view exists:
                if not view in nuke.views():
                    print('Error: Skipping invalid view: "%s"' % view)
                    continue

                    # if len( self.imgfiles):
                # self.imgfiles += ';'

                # Get show files for current view and first and last frames:
                octx = nuke.OutputContext()
                octx.setView(1 + nuke.views().index(view))
                octx_framefirst = self.framefirst
                octx_framelast = self.framelast
                if octx_framefirst < 0:
                    octx_framefirst = 0
                if octx_framelast < 0:
                    octx_framelast = 0

                # If frame first and frame last are equal no sequence needed
                if octx_framefirst == octx_framelast:
                    octx.setFrame(octx_framefirst)
                    self.imgfiles.append(fileknob.getEvaluatedValue(octx))
                else:
                    # Get files from first and last frames
                    # to calculate frames pattern:
                    octx.setFrame(octx_framefirst)
                    images1 = fileknob.getEvaluatedValue(octx)
                    if images1 is None or images1 == '':
                        nuke.message(
                            'Error:\n'
                            '%s\n'
                            'Files are empty.\n'
                            'View "%s", frame %d.' %
                            (self.writename, view, self.framefirst)
                        )
                        self.valid = False
                        return
                    octx.setFrame(octx_framelast)
                    images2 = fileknob.getEvaluatedValue(octx)
                    if images2 is None or images2 == '':
                        nuke.message(
                            'Error:\n'
                            '%s\n'
                            'Files are empty.\n'
                            'View "%s", frame %d.' %
                            (self.writename, view, self.framelast)
                        )
                        self.valid = False
                        return
                    part1, padding, part2 = \
                        afcommon.splitPathsDifference(images1, images2)

                    if padding < 1:
                        nuke.message(
                            'Error:\n'
                            '%s\n'
                            'Invalid files pattern.\n'
                            'View "%s".' %
                            (self.writename, view)
                        )
                        self.valid = False
                        return
                    self.imgfiles.append(
                        '%s@%s@%s' % (part1, '#' * padding, part2)
                    )

            # Check images folders:
            for imgfile in self.imgfiles:
                folder = os.path.dirname(imgfile)
                if folder != '':
                    if not os.path.isdir(folder):
                        result = nuke.ask(
                            'Write Node "%s" Directory\n'
                            '%s\n'
                            'Does not exist.\n'
                            'Create it?' % (self.writename, folder)
                        )
                        if result:
                            os.makedirs(folder)
                            if not os.path.isdir(folder):
                                nuke.message(
                                    "Can't create folder:\n%s" % folder
                                )
                                self.valid = False
                        else:
                            self.valid = False
        elif wnode.Class() == DailiesNodeClassName:
            if VERBOSE:
                print('Generating dailies "%s"' % self.writename)
        else:
            nuke.message('Node type\n"%s"\nis unsendable.' % self.writename)
            self.valid = False

        for par in fparams:
            if fparams[par] is not None:
                if hasattr(self, par):
                    setattr(self, par, fparams[par])

        self.name = self.writename
        if subblock:
            if self.prefix is not None:
                if self.prefix != '':
                    self.name = self.prefix + self.name

        self.dependmask = ''
        self.tasksdependmask = ''