예제 #1
0
def hlink_create():
    # Creates an hlink node for each selected node
    nodes = nuke.selectedNodes()
    unselect()
    hlinks = []
    for node in nodes:
        hlink = nuke.createNode('Dot',
                                'hide_input 1 note_font_size 18',
                                inpanel=False)
        hlinks.append(hlink)
        hlink.setInput(0, node)
        target_name = node.fullName()
        set_hlink_knobs([hlink])
        hlink['hlink_node'].setValue(target_name)
        label = hlink['label']
        target_label = node['label'].getValue()
        if node.Class() == 'Read':
            label.setValue(' | ' + node['label'].getValue() + '\n' +
                           os.path.basename(node['file'].getValue()))
        elif target_label:
            label.setValue(' | ' + target_label)
        else:
            label.setValue(' | ' + target_name)
        hlink.setXYpos(node.xpos() - grid[0] * 2, node.ypos() - grid[1] * 0)
        nuke.autoplaceSnap(hlink)
    _ = [n.setSelected(True) for n in hlinks]
예제 #2
0
def smartSnap():
    selNodes = nuke.selectedNodes()
    if selNodes == []:
        for node in nuke.allNodes():
            nuke.autoplaceSnap(node)
    else:
        for node in selNodes:
            nuke.autoplaceSnap(node)
예제 #3
0
def bakeCardTree(transformGeoNode):
    n = transformGeoNode
    while 'imgSwitch' not in n.name():
        for key in n.knobs().keys():
            kn = n.knob(key)
            if kn.hasExpression():
                #with oldGroup:
                #oldNode = nuke.toNode(n.name())
                #oldknob = oldNode.knob(kn.name())
                #v = oldknob.value()
                v = kn.value()
                kn.clearAnimated()
                kn.setValue(v)
        #deal with the expression nodes
        if n.Class() == 'Expression':
            for i in range(0, 3):
                e = 'temp_expr%s' % (i)
                n[e].setValue(n[e].value())
        #bake node a golden hue of butter subtitute
        tc_rgb = [1, 0.545, 0.196]
        tc_hex = int(
            '%02x%02x%02x%02x' %
            (tc_rgb[0] * 255, tc_rgb[1] * 255, tc_rgb[2] * 255, 1), 16)
        n['tile_color'].setValue(tc_hex)
        remove_user_knobs(n)
        n = n.dependencies()[0]

    # link up inputs and remove switchs
    switch = n
    if switch.Class() == 'Switch':
        if len(switch.dependent()) > 0:
            downstreamNode = switch.dependent()[0]
            upstreamNode = switch.input(int(switch['which'].value()))

            dot = nuke.createNode('Dot', inpanel=False)
            dot.setName('imgSwitch')
            dot.setSelected(False)
            dot.setXpos(
                int(switch.xpos() + switch.screenWidth() / 2 -
                    dot.screenWidth()))
            dot.setYpos(
                int(switch.ypos() + switch.screenHeight() / 2 -
                    dot.screenHeight()))
            #for some reason the above positioning is sometimes flakey
            nuke.autoplaceSnap(dot)

            dot.setInput(0, upstreamNode)
            downstreamNode.setInput(0, dot)
            nuke.delete(switch)
예제 #4
0
def alignNodes(nodes, axis, value, debug=0, *args):
    # align center of each node to the given axis.
    # first, to force the measurement of each node, run autoplaceSnap
    for i in nodes:
        # get current position
        x = i.xpos()
        y = i.ypos()
        nuke.autoplaceSnap(i)
        i['xpos'].setValue(x)
        i['ypos'].setValue(y)
        if axis == 'x':
            if debug:
                print 'aligning node %s to value %s=%d, node dimension is %d' % (
                    i.name(), axis, value, i.screenWidth())
            i['xpos'].setValue(int(value - (i.screenWidth() / 2)))
            # i.setXpos(int(value-(i.screenWidth()/2)))
        else:
            if debug:
                print 'aligning node %s to value %s=%d, node dimension is %d' % (
                    i.name(), axis, value, i.screenHeight())
            i['ypos'].setValue(int(value - (i.screenHeight() / 2)))
예제 #5
0
def alignGrid():
    nodes = nuke.selectedNodes()
    for n in nodes:
        nuke.autoplaceSnap(n)
예제 #6
0
def snap_to_grid():
    # Snap selected nodes to grid
    nodes = nuke.selectedNodes()
    for node in nodes:
        nuke.autoplaceSnap(node)
예제 #7
0
def resize_to_grid():
    n = nuke.thisNode();
    k = nuke.thisKnob();
    if knob_to_grid(k, 'bdwidth', grid_width) or knob_to_grid(k, 'bdheight', grid_height):
        nuke.autoplaceSnap(n)
예제 #8
0
def alignGrid():
    nodes = nuke.selectedNodes()
    for n in nodes:
        nuke.autoplaceSnap(n)