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 thisGroup = nuke.thisGroup() 22 if thisGroup is not nuke.root() and ( thisGroup.locked() or thisGroup.subgraphLocked() ) : 23 lockedReason = "published" if thisGroup.subgraphLocked() else "locked" 24 raise RuntimeError("Can't remove input because " + thisGroup.name() + " is " + lockedReason) 25 26 nodes = nuke.selectedNodes() 27 for i in nodes: 28 for j in range(i.inputs()): i.setInput(j, None)
29
30 -def extract():
31 """Disconnect all arrows between selected and unselected nodes, and move selected nodes to the right. 32 This function is maintained only for compatibility. Please use nuke.extractSelected() instead.""" 33 nuke.extractSelected()
34
35 -def branch():
36 thisGroup = nuke.thisGroup() 37 if thisGroup is not nuke.root() and ( thisGroup.locked() or thisGroup.subgraphLocked() ) : 38 lockedReason = "published" if thisGroup.subgraphLocked() else "locked" 39 raise RuntimeError("Can't branch because " + thisGroup.name() + " is " + lockedReason) 40 41 top_node = None 42 selnodes = nuke.selectedNodes() 43 for i in selnodes: 44 totalinputs = i.inputs() 45 for j in range(totalinputs): 46 if i.input(j).knob("selected").value() is False: 47 top_node = i.input(j) 48 49 if top_node is None: return 50 51 nuke.nodeCopy(nukescripts.cut_paste_file()) 52 nuke.nodePaste(nukescripts.cut_paste_file()) 53 54 firstpastenode = None 55 56 selnodes = nuke.selectedNodes() 57 for i in selnodes: 58 firstpastenode = i 59 xpos = i.knob("xpos").value() 60 i.knob("xpos").setValue(xpos+80) 61 62 if firstpastenode is not None: 63 firstpastenode.setInput(0, top_node)
64