7

My screen has different areas: one 3D View and two Image Editors.

I would like to split one of the Image Editors but when I call the bpy.ops.screen.area_split() operator, it's always going to split the 3D View for whatever reason.

Does anyone know how I can split a certain area?

brockmann
  • 12,613
  • 4
  • 50
  • 93
miaou
  • 73
  • 3
  • 1
    Related https://blender.stackexchange.com/questions/44427/splitting-of-screen-areas-and-retrieving-the-active-area-with-python https://blender.stackexchange.com/questions/56911/how-to-open-a-new-editor-with-python – batFINGER Mar 13 '21 at 08:57

1 Answers1

7

Iterate through all visible areas and override the context when calling area_split() operator.

Blender 3.2+

import bpy
from bpy import context

for area in context.screen.areas: if area.type == 'IMAGE_EDITOR': # 'VIEW_3D', 'CONSOLE', 'INFO' etc. with context.temp_override(area=area): bpy.ops.screen.area_split(direction='VERTICAL', factor=0.3) break

Blender 2.8+

import bpy

for area in bpy.context.screen.areas: if area.type == 'IMAGE_EDITOR': # 'VIEW_3D', 'CONSOLE', 'INFO' etc. override = bpy.context.copy() override['area'] = area bpy.ops.screen.area_split(override, direction='VERTICAL', factor=0.3) break

p2or
  • 15,860
  • 10
  • 83
  • 143
brockmann
  • 12,613
  • 4
  • 50
  • 93