A set of operators is provided in Blender for manipulating with the location of its interface windows.
To split the current window (using the current context) into two in a specified ratio, we need to execute the following operator:
1 |
bpy.ops.screen.area_split(direction='VERTICAL', factor=0.5) |
With:
- direction – set the splitting direction (‘HORIZONTAL’ or ‘VERTICAL’)
- factor – percentage ratio of splitting windows
A new window (new area) is appended to the end of the bpy.context.screen.areas list and can be obtained through the:
1 |
new_area = bpy.context.screen.areas[-1] |
To join two windows into one, we need to execute the following operator:
1 |
bpy.ops.screen.area_join(cursor=(x1, y1)) |
With:
- x1, y1 – left top corner coordinates of the joined window (area)
Area corner coordinates we can get from the area “x” and “y” properties:
1 2 3 4 |
bpy.context.screen.areas[-1].x # 1259 bpy.context.screen.areas[-1].y + bpy.context.screen.areas[-1].width # 912 |