nukescripts.edit

Package nukescripts :: Module edit |
[hide private]
[frames] | no frames]

# Source Code for Module nukescripts.edit

     1  # Copyright (c) 2009 The Foundry Visionmongers Ltd.  All Rights Reserved.
     2
     3  # cut the current node and then paste a copy after every other node.
     4  # This was a throb invention, not sure how useful it is.
     5
     6  import nuke
     7  import nukescripts
     8
     9  # Edit menu
    10 -def cut_paste_file():
    11          return "%clipboard%"
    12
    13 -def node_copypaste():
    14    nuke.nodeCopy(cut_paste_file())
    15    nodes = nuke.allNodes();
    16    for i in nodes:
    17      i.knob("selected").setValue(False)
    18    nuke.nodePaste(nukescripts.cut_paste_file())
    19
    20 -def remove_inputs():
    21    nodes = nuke.selectedNodes()
    22    for i in nodes:
    23      for j in range(i.inputs()): i.setInput(j, None)
    24
    25 -def extract():
    26    """Disconnect all arrows between selected and unselected nodes, and move selected nodes to the right.
    27    This function is maintained only for compatibility.  Please use nuke.extractSelected() instead."""
    28    nuke.extractSelected()
    29
    30 -def branch():
    31    top_node = None
    32    selnodes = nuke.selectedNodes()
    33    for i in selnodes:
    34      totalinputs = i.inputs()
    35      for j in range(totalinputs):
    36        if i.input(j).knob("selected").value() is False:
    37          top_node = i.input(j)
    38
    39    if top_node is None: return
    40
    41    nuke.nodeCopy(nukescripts.cut_paste_file())
    42    nuke.nodePaste(nukescripts.cut_paste_file())
    43
    44    firstpastenode = None
    45
    46    selnodes = nuke.selectedNodes()
    47    for i in selnodes:
    48      firstpastenode = i
    49      xpos = i.knob("xpos").value()
    50      i.knob("xpos").setValue(xpos+80)
    51
    52    if firstpastenode is not None:
    53      firstpastenode.setInput(0, top_node)
    54