0

Override method work only if I have opened image editor and "Render Result" is selected there

import bpy

for area in bpy.context.screen.areas: if area.type == 'IMAGE_EDITOR': override = bpy.context.copy() override['area'] = area bpy.ops.image.add_render_slot(override) break

APEC
  • 570
  • 3
  • 12

1 Answers1

1

This script will switch the Editor Type to IMAGE_EDITOR and set the active image as bpy.data.images['Render Result'].

import bpy

area_type = 'IMAGE_EDITOR'

bpy.context.area.ui_type = area_type # or use (bpy.context.window.screen.areas[5].ui_type = area_type) to change another area to image editor

areas = [area for area in bpy.context.window.screen.areas if area.type == area_type] area = areas[0] area.spaces.active.image = bpy.data.images['Render Result']

override = { 'window': bpy.context.window, 'screen': bpy.context.window.screen, 'area': area, 'region': [region for region in area.regions if region.type == 'WINDOW'][0], }

bpy.ops.image.add_render_slot(override)

Harry McKenzie
  • 10,995
  • 8
  • 23
  • 51