Compositor backdrop?

Okay, I’ll keep it simple.

What is ‘the best way’ of activating the backdrop function in the compositor with a python script?

Thanks,

GB

The best way I know:


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

hmm, I’ve seen a similar way of doing it like this:

import bpy

for area in bpy.context.screen.areas:
    if area.type == 'DOPESHEET_EDITOR':
        space_data = area.spaces.active
        break
else:
    space_data = None

if space_data is not None:
    pass

found here by CoDEmanX: http://blender.stackexchange.com/questions/14708/how-can-i-get-a-particular-editor-space-in-python.

But, the solution that you and he suggested only works if the space I wanna reach is opened on your screen somewhere. I actually found a better solution recently, which is this:

area = bpy.context.area
old_area = area.type
area.type = 'NODE_EDITOR'
space_data = area.spaces.active
space_data.show_backdrop = True
area.type = old_area

found here also by CoDEmanX: http://blender.stackexchange.com/questions/6101/poll-failed-context-incorrect-example-bpy-ops-view3d-background-image-add.

Had no idea you could set the active area that easy. This does work well, but can you access a certain space (like the node editor) without actually changing the space in blender? Because that would be even better than this. And, I wonder, how come you can access other functions in the node editor without actually being in that space but not the backdrop function?

Thanks for your reply anyways! :slight_smile:

I would think because of the different data paths. Since the backdrop is part of the space, that space would have to exist somewhere. I’m just assuming though.

Agree, thought so too, anyone know?