I'm trying to set a key bind to activate the screen.area_split
so that I don't have to use the mouse, and instead splits the screen 50/50 down the middle. Does anyone know how to achieve this?
1 Answer
You have to create two Operators
for splitting area horizontally and another one for splitting area vertically with the following script. Copy and paste this in the Text Editor
under the Scripting Tab and click Run Script button to generate these operators.
import bpy
class SplitAreaHorizontalOperator(bpy.types.Operator):
bl_idname = "screen.splitarea_horizontal_operator"
bl_label = "Split Area Horizontal Operator"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.screen.area_split(direction='HORIZONTAL', factor=0.5)
return {'FINISHED'}
def register():
bpy.utils.register_class(SplitAreaHorizontalOperator)
def unregister():
bpy.utils.unregister_class(SplitAreaHorizontalOperator)
if __name__ == "__main__":
register()
#bpy.ops.screen.splitarea_horizontal_operator()
class SplitAreaVerticalOperator(bpy.types.Operator):
bl_idname = "screen.splitarea_vertical_operator"
bl_label = "Split Area Vertical Operator"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
bpy.ops.screen.area_split(direction='VERTICAL', factor=0.5)
return {'FINISHED'}
def register():
bpy.utils.register_class(SplitAreaVerticalOperator)
def unregister():
bpy.utils.unregister_class(SplitAreaVerticalOperator)
if __name__ == "__main__":
register()
#bpy.ops.screen.splitarea_vertical_operator()
Check by pressing F3 anywhere and type/search split area to see if they have been registered. Then test them if they work properly.
You can do a keybind via script as explained in this thread but I'm going to add them manually under Edit > Preferences > Keymap > Screen and then expand Screen (Global).
At the bottom of the key binding list, add your key binding to the list and search for the operator screen.splitarea_horizontal_operator
.
In this example, I added and configured a keybinding of Ctrl+K for splitting horizontally. Add another one for the vertical split operator screen.splitarea_vertical_operator
.