Пример #1
0
def extracard():
    cardnames = []
    for card in nuke.allNodes("Card2"):
        if "Card_Matte_" in card.name():
            cardnames.append(int(card.name()[11:]))

    currentcardmax = max(cardnames)
    currentcardmax += 1

    mattecard = nuke.nodes.Card2(name="Card_Matte_{}".format(currentcardmax),
                                 label="Dist: [value z]",
                                 xpos=150 * (currentcardmax - 1),
                                 ypos=0,
                                 z=5 * (currentcardmax))

    checker = nuke.nodes.CheckerBoard2(name="Checker_matte " +
                                       str(currentcardmax),
                                       centerlinewidth=0,
                                       xpos=150 * (currentcardmax - 1),
                                       ypos=-100)

    mattecard.setInput(0, checker)

    mattecard['lens_in_focal'].setExpression("Camera_MATTE.focal")
    mattecard['lens_in_haperture'].setExpression("Camera_MATTE.haperture")

    mattescn.setInput(currentcardmax, mattecard)
    mattecard.setSelected(True)
    checker.setSelected(True)

    nuke.zoomToFitSelected()
    for n in nuke.allNodes():
        n.setSelected(False)
Пример #2
0
def jumpTo(nodeName):
    node = nuke.toNode(nodeName)
    for s in nuke.selectedNodes():
        s['selected'].setValue(False)

    node['selected'].setValue(True)
    nuke.zoomToFitSelected()
Пример #3
0
def getMissingFrames(node):
    parent = os.path.dirname(node['file'].value())
    if len(nuke.getFileNameList(parent)) > 1:
        nuke.selectAll()
        nuke.invertSelection()
        node.setSelected(1)
        nuke.zoomToFitSelected()
        nuke.message('missing frames: ' +
                     ",".join(nuke.getFileNameList(parent)))
Пример #4
0
 def Focus(self,node,p):
     if nuke.selectedNodes() is None:
         pass
     else:
         sn = nuke.selectedNodes()
     if len(sn):
         for b in sn:
             b['selected'].setValue(False)
             
     print node
     
     kn = list(node)
     kn.remove('#')
     knn = ''.join(kn)
     a = nuke.toNode(knn)
     a.knob('selected').setValue(True)
     nuke.zoomToFitSelected()
     if p.styleSheet() != "QPushButton {color: green;}":
         p.setStyleSheet('QPushButton {color: #ffc78e;}')
     print p.styleSheet()
Пример #5
0
                           "\n        if source is not None and 'translate' in source.knobs().keys() and target is not None and 'translate' in target.knobs().keys():"
                           "\n            distance = math.sqrt(((source['translate'].getValue()[0] - target['translate'].getValue()[0])**2)+((source['translate'].getValue()[1] - target['translate'].getValue()[1])**2)+((source['translate'].getValue()[2] - target['translate'].getValue()[2])**2))"
                           "\n            knob.setValue('<font color =lime>'+str(round(distance,3)).zfill(10))"
                           "\n        else:"
                           "\n            knob.setValue('000000.000')"
                           "\nret=0}]")
sticky_note.addKnob(format2_knob)
format2_knob.setFlag(0x00000400)


format3_knob = nuke.Int_Knob('format3', '')
format3_knob.setExpression("[python -execlocal {for knob in nuke.thisNode().allKnobs():"
                           "\n    if 'source_row_' in knob.name() and nuke.toNode(knob.value()) is not None:"
                           "\n        if 'translate' not in nuke.toNode(knob.value()).knobs().keys():"
                           "\n            knob.setValue('')"
                           "\n    if 'target_row_' in knob.name() and nuke.toNode(knob.value()) is not None:"
                           "\n        if 'translate' not in nuke.toNode(knob.value()).knobs().keys():"
                           "\n            knob.setValue('')"
                           "\nret=0}]")
sticky_note.addKnob(format3_knob)
format3_knob.setFlag(0x00000400)


# -------------------------------- FRAMING -------------------------------- #

sticky_note.setSelected(True)
nuke.show(sticky_note)
nuke.zoomToFitSelected()
for n in nuke.allNodes():
    n.setSelected(False)
Пример #6
0
def board_creation():
    # Changes to the scene
    nuke.toNode('preferences')['DAGBackColor'].setValue(backColor)

    # Progress bar
    nodes_progress = nuke.ProgressTask('Battleship game')
    nodes_progress.setMessage('Creating board')
    nodes_progress.setProgress(20)

    # CREATION OF BOARD
    # Creation of squares
    for i in range(0, totalSize, dotDistance):

        for j in range(0, totalSize, dotDistance):

            if j % squareSize == 0 or i % squareSize == 0:
                nuke.nodes.Dot(name='Dot_COM_bShip',
                               xpos=j,
                               ypos=i,
                               hide_input=True,
                               tile_color=1720943359)

                nuke.nodes.Dot(name='Dot_USER_bShip',
                               xpos=j,
                               ypos=i + user_com_distance,
                               hide_input=True,
                               tile_color=1720943359)

    nodes_progress.setProgress(60)

    # Creation of divider and COM/USER tags
    if squareNumber > 7:

        separation = totalSize + ((user_com_distance - totalSize) / 2)

        for X in range(-1, squareNumber + 4):
            no_op = nuke.nodes.NoOp(xpos=(X * 80) - 120,
                                    ypos=separation - 30,
                                    hide_input=True)

            no_op['name'].setValue('')

            if X == -1:
                nuke.nodes.StickyNote(name='COMtagbShip',
                                      label='COM',
                                      note_font='Arial Bold',
                                      note_font_size=25,
                                      note_font_color=4278190335,
                                      tile_color=backColor,
                                      xpos=(X * 80) - 120,
                                      ypos=separation - 100)

                nuke.nodes.StickyNote(name='USERtagbShip',
                                      label='USER',
                                      note_font='Arial Bold',
                                      note_font_size=25,
                                      note_font_color=536805631,
                                      tile_color=backColor,
                                      xpos=(X * 80) - 120,
                                      ypos=separation + 25)

    nodes_progress.setProgress(80)

    # Creation of coord labels
    label_size = 29
    for N in range(0, squareNumber):
        nuke.nodes.StickyNote(xpos=N * squareSize + 5,
                              ypos=-50,
                              note_font='Arial Black Bold Bold Bold Bold',
                              note_font_size=label_size,
                              tile_color=backColor,
                              label=str(N + 1),
                              name='bShip' + str(N + 1))

        nuke.nodes.StickyNote(xpos=N * squareSize + 5,
                              ypos=-50 + user_com_distance,
                              note_font='Arial Black Bold Bold Bold Bold',
                              note_font_size=label_size,
                              tile_color=backColor,
                              label=str(N + 1),
                              name='bShip' + str(N + 1))

        nuke.nodes.StickyNote(xpos=-80,
                              ypos=N * squareSize + 28,
                              note_font='Arial Black Bold Bold Bold Bold',
                              note_font_size=label_size,
                              tile_color=backColor,
                              label=string.uppercase[N],
                              name='bShip' + string.uppercase[N])

        nuke.nodes.StickyNote(xpos=-80,
                              ypos=N * squareSize + 28 + user_com_distance,
                              note_font='Arial Black Bold Bold Bold Bold',
                              note_font_size=label_size,
                              tile_color=backColor,
                              label=string.uppercase[N],
                              name='bShip' + string.uppercase[N])

    nodes_progress.setProgress(100)
    del nodes_progress

    # Framing the nodes
    for node in nuke.allNodes():
        node.setSelected(True)
    nuke.zoomToFitSelected()
    for node in nuke.allNodes():
        node.setSelected(False)

    # Changes to the Main node
    kMainButton.setLabel('<b><font size = 6>FIRE!')
    kMainButton.setValue('user_fires()')
    kInfo.setValue('''How to to fire:
-Select a coordinate (yellow dot node)
-Press the FIRE! button''')
Пример #7
0
    def autoplace(self, node):
        """Autoplace single node.  """
        def _base_node():
            if base_node and base_node in self.nodes:
                assert isinstance(base_node, nuke.Node)
                base_dep = base_node.dependencies(nuke.INPUTS)
                self_index = base_dep.index(node)
                is_new_branch = self.is_new_branch(node)
                xpos = base_node.xpos(
                ) + base_node.screenWidth() / 2 - node.screenWidth() / 2
                ypos = base_node.ypos() - self.y_gap - max(
                    node.screenHeight(), self.min_height)
                if self_index == 0:
                    pass
                elif is_new_branch and self.placed_nodes:
                    xpos = Nodes(self.placed_nodes).right + self.x_gap * 50
                else:
                    prev_node = base_dep[self_index - 1]
                    xpos = prev_node.xpos()\
                        + int(1.5 * max(prev_node.screenWidth(), self.min_width))  \
                        - node.screenWidth() / 2 + self.x_gap

                if not is_new_branch:
                    # Replace prev nodes
                    prev_nodes = Nodes(self.get_prev_nodes(node))
                    if prev_nodes:
                        prev_nodes.bottom = min(ypos - self.y_gap,
                                                prev_nodes.bottom)
                return (xpos, ypos)

        def _backdrop():
            backdrop = self.backdrop
            padding = self.backdrop_padding

            if backdrop:
                assert isinstance(backdrop, nuke.Node)

                backdrop = Nodes(backdrop)
                xpos = backdrop.xpos + padding.left
                ypos = backdrop.bottom - padding.bottom - node.screenHeight()
                return (xpos, ypos)

        def _placed_nodes():
            if self.placed_nodes:
                nodes = Nodes(self.placed_nodes)
                xpos = nodes.right + self.x_gap * 10
                ypos = -node.screenHeight()
                return (xpos, ypos)

        def _all_nodes():
            if not set(nuke.allNodes()).difference(self.nodes):
                xpos = 0
                ypos = -node.screenHeight()
                return (xpos, ypos)

        def _default():
            xpos = self.nodes.xpos
            ypos = self.nodes.bottom - self.min_height
            return (xpos, ypos)

        base_node = self.get_base_node(node)
        methods = (_base_node, _backdrop, _placed_nodes, _all_nodes, _default)
        pos = None
        method = None
        for method in methods:
            pos = method()
            if pos:
                node.setXYpos(*pos)
                break
        else:
            raise RuntimeError('No autoplace method can be used.')

        if not base_node:
            self.prev_branch_nodes.update(self.placed_nodes)
        self.placed_nodes.add(node)

        if DEBUG:
            # node.selectOnly()
            nuke.zoomToFitSelected()
            if not nuke.ask(
                    '{}:\nbase:{}\nup count:{}\nmethod:{}\nx: {} y: {}'.format(
                        self.get_count(node), method.__name__, *pos)):
                raise RuntimeError