Hey there,<br>
<br>
i’m new to this forum.<br>
I need to split an area after pressing a button operator. In my execute definition of the operator i call ‘bpy.ops.screen.area_split(direction=‘HORIZONTAL’, factor = 0.5, mouse_x = -100, mouse_y=-100)’ and as I suspected it won’t work. How can I define the concrete area to split?<br>
And also if I enable a shortcut for area split in the system settings, nothing will change when pressing the key.<br>
<br>
Oh and i’m using Blender 2.71…<br>
<br>
Hope anyone can help :-)<br>
Thanks and greetings<br>
<br>
Mehari
Here is an example you could take a look at:
https://github.com/dustractor/areatype_split/blob/master/areatype_split_view_w_uv.py
It puts a button on the 3d view header that you can click to toggle a split with the image editor, but it should be easy to modify where it goes and what space-type it splits with.
bl_info = {
"name": "Areatype Split (3D View/UV Editor)",
"description":"This example adds a button which toggles a split of an area with another.",
"author":"[email protected]",
"version":(0,1),
"blender":(2,65,0),
"location":"Prepended to the header of the viewport.",
"warning":"",
"wiki_url":"",
"category": "System"
}
import bpy
class AREATYPE_OT_split(bpy.types.Operator):
bl_idname = "areatype.splitview"
bl_label = "areatype.splitview"
def execute(self,context):
thisarea = context.area
otherarea = None
tgxvalue = thisarea.x + thisarea.width + 1
thistype = context.area.type
arealist = list(context.screen.areas)
for area in context.screen.areas:
if area == thisarea:
continue
elif area.x == tgxvalue and area.y == thisarea.y:
otherarea = area
break
if otherarea:
bpy.ops.screen.area_join(min_x=thisarea.x,min_y=thisarea.y,max_x=otherarea.x,max_y=otherarea.y)
bpy.ops.screen.screen_full_area()
bpy.ops.screen.screen_full_area()
return {"FINISHED"}
else:
context.area.type = "IMAGE_EDITOR"
areax = None
bpy.ops.screen.area_split(direction="VERTICAL")
for area in context.screen.areas:
if area not in arealist:
areax = area
break
if areax:
areax.type = thistype
return {"FINISHED"}
return {"CANCELLED"}
def viewdraw(self,context):
layout = self.layout
layout.operator("areatype.splitview",text="",icon="COLOR_BLUE")
def register():
bpy.types.VIEW3D_HT_header.prepend(viewdraw)
bpy.utils.register_module(__name__)
def unregister():
bpy.types.VIEW3D_HT_header.remove(viewdraw)
bpy.utils.unregister_module(__name__)
Thank you! That was what I was looking for!