Is it possible to enable backdrop using Python?


(Warrior) #1

I am trying to enable backdrop in Blender using Python but it seems that it is not as straight-forward as I thought. I know how to enable Use Nodes via

bpy.context.scene.use_nodes = True

and just need to enable backdrop. The relevant Python documentation for backdrop Here is a bit unclear and I do not know exactly how I can enable backdropping through the NodeSpaceEditor class. Can someone explain how I can do that?

The hard way is to compile Blender from scratch and enable backdropping by modifying the source code as explained here but this is too much of work. I hope there is a way to do it using Blender’s Python API.


(AFWS) #2

I’m assuming you posted here https://blender.stackexchange.com/questions/103075/is-it-possible-to-enable-backdrop-using-python too? If you haven’t figured it out you have to do something like this to run from text editor.

import bpy

for area in bpy.context.screen.areas:
    if area.type == 'NODE_EDITOR':
        area.spaces.active.show_backdrop = True

(Warrior) #3

Thank you for your answer. The problem is I am running Blender in the background (no UI) and use Blender’s Python API to do things. Therefore, I do not have access to node editor area. Do you know how can I do that? I should have been more clear in my question and I apologize for being confusing.


(AFWS) #4

I’ve never used blender without the UI, so not sure. You could try what was mentioned in the other thread. Make a window the node editor and then save your startup file.


(Martynas Žiemys) #5

I am curious - in what context does it make sense to control elements of the UI without having the UI?


(Warrior) #6

I want to run Blender in the background and do millions of renderings. To get around the IO overhead I want to directly store the rendering results in Numpy arrays and store them on disk in big chunks. I have tried different methods to update the “Viewer Node” image block when adding new Viewer nodes in the Node Editor. However, it seems that the contents of the “Viewer Node” image block do not get updated unless you click on the newly-added Viewer node. From here, I realized that it is probably impossible to simulate clicking. Then I realized that activating backdrop will automatically update the contents of the image block when a new Viewer node is added as shown here. However, I do not know how to activate backdrop without having access to the UI. I even tried compiling Blender from source and made the changes proposed here. But it seems that that also does not work. The only way that I could get things to work was to run the rendering function once I add a new Viewer node which does not make sense (it takes longer than saving files on disk after each rendering). think there is a bug in Blender that does not allow this happen. I posted a bug report here.

Anyways, let me know if you know any solutions or a way to get around the issue.