I'm working on a script which should add a trim mode to the sequencer. The preview area is split into two preview areas, until the trimming has finished and the two areas are joined again, but I can't figure out how to get the values needed for the area_join function right. How do I get the script to join the two areas into one area again?

Some example code:

import bpy

original_area = bpy.context.area

for region in original_area.regions:
    if region.type == 'WINDOW':

start_areas = bpy.context.screen.areas[:]

bpy.ops.screen.area_split(direction='VERTICAL', factor=0.5) # Split

#[Here things will happen(modal trimming) in the two preview areas before they will be joined into one again]

for area in bpy.context.screen.areas:
    if area not in start_areas:

for region in new_area.regions:
    if region.type == 'WINDOW':
        new_area_x=region.x + region.width 
        new_area_y=region.y + region.height 

print("ox "+str(old_area_x))
print("oy "+str(old_area_y))
print("nx "+str(new_area_x))
print("ny "+str(new_area_y))

# I'm not sure I understand these values right?
bpy.ops.screen.area_join(min_x=old_area_x, min_y=old_area_y, max_x=new_area_x, max_y=new_area_y) #Join - not working

A few words on what I need this function for: https://blenderartists.org/t/wip-vse-quick-functions-snaps-fades-zoom-parenting-titling-play-speed/611831/93

Trim-mode for Sequencer

up vote 1 down vote accepted

I found a script by dustractor, which adds a toggle button to the header of the 3d View which splits and joins the area: https://github.com/dustractor/areatype_split/blob/master/init.py

The values of the working(vertical) area_join function seems to be:

  • min_x = Left x of left window
  • min_y = Mouse position, starting from window bottom y (when clicking button)
  • max_x = X position between left and right window
  • max_y = Mouse position, starting from window bottom y (when clicking button)

Here's my version, with a working button in the sequencer header area:

bl_info = {
        "name": "Areatype Trim",
        "description":"This example adds a button which toggles a split of an area with another.",
        "author":"dustractor@gmail.com, tintwotin",
        "location":"Button prepended to the header of the sequencer.",
        "category": "Sequencer"

import bpy

class AREATYPE_OT_trim(bpy.types.Operator):
    bl_idname = "areatype.trimview"
    bl_label = "Trim"

    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:
            elif area.x == tgxvalue and area.y == thisarea.y:
                otherarea = area
        if otherarea: #leave trim-mode
            print("this x: "+str(thisarea.x))   #min_x = left x of left window 
            print("this y: "+str(thisarea.y))   #min_y = mouse position, starting from window bottom y
            print("other x: "+str(otherarea.x)) #max_x = x between left and right window
            print("other y: "+str(otherarea.y)) #max_y = mouse position, starting from window bottom y

            bpy.context.space_data.overlay_type = 'CURRENT' 
            return {"FINISHED"}
        else: # enter trim-mode
            bpy.context.space_data.overlay_type = 'REFERENCE'          
            areax = None
            for area in context.screen.areas:
                if area not in arealist:
                    areax = area
            if areax:
                areax.type = thistype
                return {"FINISHED"}
        return {"CANCELLED"}

def draw_func(self,context):
    layout = self.layout

def register():

def unregister():

if __name__ == "__main__":

This is where I am with the trim-script right now: https://gist.github.com/tin2tin/b7fd08762d1d8290626ee299488e2798


Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.