I try to split the VIEW_3D area of my screen (2/3 - 1/3), and to display in the 1/3 a file with the TEXT_EDITOR.
The problems are:
that the activate area seems not follow the area's iteration
the width of the new area created seems not to have been update. (0 is returned)
here is the code:
bpy.context.area.type = 'VIEW_3D'
orig_width = bpy.context.area.width
print("originale width of View 3D is : " + str(orig_width))
bpy.ops.screen.area_split(direction='VERTICAL', factor=0.3)
final_width = round(bpy.context.area.width * 0.3, 0)
print("Final width of View 3D is : " + str(final_width))
i = 0
for ecran in bpy.context.screen.areas:
print(ecran.type)
if ecran.type == 'VIEW_3D':
print("Space.active = " + str(ecran.spaces.active))
current_width = bpy.context.area.width
print(str(current_width) + " - current_width")
print("i = " + str(i) + " - " + bpy.context.screen.areas[i].type + "Width : " + str(bpy.context.screen.areas[i].width))
if current_width == final_width:
print(ecran.spaces[i].type)
bpy.types.spaces[i] == 'TEXT_EDITOR'
i = i + 1
The script is executing from an addon in the context of 3d_view, called from the spacebar menu. It splits correctly but the Text_Editor is not displayed.