Custom Scripts VII: Quick custom backdrop

I love to keep my nodegraph tidy and organize, so I use to pack nodes related to certain tasks in backdrops with titles. I don’t like the randomness of the backdrop color that Nuke has by default. I created a hotkey (Shift+1) and linked this script to it.

This script creates a backdrop with certain default attributes (color and label, in this case) grouping a node selection, allowing me to organize my nodegraph quicker.

def bg_preset01():
    selNodes = nuke.selectedNodes()
    nodeGroup = []
    for nodes in selNodes:
        nodeGroup.append(nodes.name())
    bg = nuke.createNode('BackdropNode', inpanel=False)
    bg['tile_color'].setValue(3132799489)
    bg['label'].setValue('<center>')
    bg['note_font_size'].setValue(50)
    padding = 50
    bgX = min([nuke.toNode(i).xpos() for i in nodeGroup]) - padding
    bgY = min([nuke.toNode(i).ypos() for i in nodeGroup]) - padding
    bgW = max([nuke.toNode(i).xpos() + nuke.toNode(i).screenWidth() for i in nodeGroup]) - bgX + padding
    bgH = max([nuke.toNode(i).ypos() + nuke.toNode(i).screenHeight() for i in nodeGroup]) - bgY + padding
    bg['xpos'].setValue(bgX)
    bg['ypos'].setValue(bgY)
    bg['bdwidth'].setValue(bgW)
    bg['bdheight'].setValue(bgH)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.