0
$\begingroup$

i want to change the active image of my uv/editor with codes, i dont know how to do this in 2.8

could someone help ?

$\endgroup$

2 Answers 2

1
$\begingroup$

Try this:

import bpy

for area in bpy.context.screen.areas:
    if area.type == 'IMAGE_EDITOR':
        area.spaces.active.image = bpy.data.images['Your_image_name']

Deactivate image in Image Editor

for area in bpy.context.screen.areas:
    if area.type == 'IMAGE_EDITOR':
        area.spaces.active.image = None
$\endgroup$
0
$\begingroup$

I needed this to work even if Image Editor is in different window so I used an additional loop for Bleneder windows:

import bpy
img = bpy.data.images.load('My Image.png')
for window in bpy.data.window_managers['WinMan'].windows:
    for area in window.screen.areas:
        if area.type == 'IMAGE_EDITOR':
            area.spaces.active.image = img
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .