1
2
3 import nuke, random
4
6 '''
7 Automatically puts a backdrop behind the selected nodes.
8
9 The backdrop will be just big enough to fit all the select nodes in, with room
10 at the top for some text in a large font.
11 '''
12 selNodes = nuke.selectedNodes()
13 if not selNodes:
14 return nuke.nodes.BackdropNode()
15
16
17 bdX = min([node.xpos() for node in selNodes])
18 bdY = min([node.ypos() for node in selNodes])
19 bdW = max([node.xpos() + node.screenWidth() for node in selNodes]) - bdX
20 bdH = max([node.ypos() + node.screenHeight() for node in selNodes]) - bdY
21
22
23 left, top, right, bottom = (-10, -80, 10, 10)
24 bdX += left
25 bdY += top
26 bdW += (right - left)
27 bdH += (bottom - top)
28
29 n = nuke.nodes.BackdropNode(xpos = bdX,
30 bdwidth = bdW,
31 ypos = bdY,
32 bdheight = bdH,
33 tile_color = int((random.random()*(16 - 10))) + 10,
34 note_font_size=42)
35
36
37 n['selected'].setValue(False)
38 for node in selNodes:
39 node['selected'].setValue(True)
40
41 return n
42