Backdrop Node Presets

Categories Python, Workflow

Humans are creatures of habit. To align with this mindset, I have created a python script that enables compositors to set Backdrop Node presets in their menu.py!

I appreciate having consistent defaults, as it helps our lizard brains instantly recognize what is what at a glance, without thinking about it. If I’m zoomed out all the way on a massive Nuke script, I know the green areas are Keys, purple areas are DMPs, etc. etc.

Scroll down to see the code, or Click here if you simply want to download the code, the presets I’ve set in my own menu.py, and all the coloured icons.

You may notice the defaultBackdrop() function has a few parameters, that help control things:
Name: The label of your BackdropNode to display in the node graph
bgColR: Red value of the BackdropNode’s colour
bgColG: Green value of the BackdropNode’s colour
bgColB: Blue value of the BackdropNode’s colour
tColR: Red value of the text colour
tColG: Green value of the text colour
tColB: Blue value of the text colour
zIndex: Controls layering in relation to other Backdrop Nodes

These parameters control the aspects we want to change when we create the presets in our menu.py. Speaking of, let’s dive into the code and see how it all works! I’ve commented the code, to make it more human-readable.

Highlight the code to scroll across & read it all, or click the “backdropDefaults.py” link down the bottom to view the code on GitHub.

Click here to download the code, the presets I’ve set in my own menu.py, and all the coloured icons.

Tip: When creating your own presets, you can easily find the RGB colour values you want to use by opening a colour picker and copy/pasting the RGB values from there.

——————–
If you liked this post, and would like to gain a better understanding of the fundamentals of Python in Nuke, check out my course: Python for Nuke 101.

9 thoughts on “Backdrop Node Presets

  1. I’ve learned so much from your python 101 and I found this and applied it to my nuke. but since I am so new to python, I struggle to figure out changes between python 2 and 3. this setup works on my nuke 12 but not on 13. How do I fix this error ” %x format: an integer is required, not float”?

  2. I searched and searched how to fix the problem before I put the comment here but I finally figured it out after I posted. I added int() to each bgColR,G,B. you can disregard my question and post!

    1. DO i have to change the defaultBackdrop.py or the menu.py?
      I don’t get it. Can you please share an example of your file?
      Thank you 🙂

  3. I got it!
    I edited my menu.py file:

    from:
    bmBackdrops.addCommand(‘Generic’, ‘defaultBackdrop.defaultBackdrop(” “, 0.267, 0.267, 0.267, 0.498, 0.498, 0.498, -5)’, ‘alt+b’, icon=”Backdrop.png”)

    to:
    bmBackdrops.addCommand(‘Generic’, ‘defaultBackdrop.defaultBackdrop(” “, int(0.267), int(0.267), int(0.267), int(0.498), int(0.498), int(0.498), -5)’, ‘alt+b’, icon=”Backdrop.png”)

    this converts the float to integer!

    1. Hi, I tried to do the same thing as you did, but it eventually turns all the backdrop nodes to black, any thoughts why it is doing that?
      Thank you.

  4. OK finaly i got it working for Nuke 14.2
    (sorry for older comments)
    ————

    The only thing we need to change is in the “defaultBackdrop.py”
    no changes needet to menu.py

    change:

    # Define Colors
    bgColor = int(‘%02x%02x%02x%02x’ % (bgColR*255,bgColG*255,bgColB*255,255),16)
    textColor = int(‘%02x%02x%02x%02x’ % (tColR*255,tColG*255,tColB*255,255),16)

    to:

    # Define Colors
    bgColor = int(‘%02x%02x%02x%02x’ % (int(bgColR*255),int(bgColG*255),int(bgColB*255),255),16)
    textColor = int(‘%02x%02x%02x%02x’ % (int(tColR*255),int(tColG*255),int(tColB*255),255),16)

Leave a Reply

Your email address will not be published. Required fields are marked *

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