2
$\begingroup$

How to add equal distance between the selected strips ?

Is there a script to access strips it will be great ?

Note: The I am aware or Shift + = to remove the gap between strips I want to do the reverse of it I want to add equal space

enter image description here

$\endgroup$
4
$\begingroup$

I turned your question into one of my example scripts. I'll include it inline because that's how stackexchange works:

import bpy


def gap_strips(strips, gap):
    strips = sorted(strips, key=lambda strip: strip.frame_start)

    cleanup = []
    for i in range(1, len(strips)):
        st0 = strips[i-1]
        st1 = strips[i]
        cleanup.append( [ st1, st1.channel ])
        st1.frame_start = st0.frame_start + st0.frame_final_duration + gap
    # blender's anti-overlap code might change the channel.  put it back.
    for x in cleanup:
        x[0].channel = x[1]

def gap_selected_strips(gap):
    gap_strips( bpy.context.selected_editable_sequences , gap)


gap_selected_strips(15)
$\endgroup$
  • $\begingroup$ it makes some strips jump up channels $\endgroup$ – Chebhou Mar 27 '15 at 19:18
  • 1
    $\begingroup$ This should probably operate on bpy.context.selected_editable_sequences, so it doesn't behave strangely while inside meta-strips. $\endgroup$ – ideasman42 Mar 27 '15 at 19:24
  • $\begingroup$ Hopefully the latest version fixes the shortcomings you both identified. $\endgroup$ – Mutant Bob Mar 31 '15 at 15:24
-1
$\begingroup$

Improvised from @Mutant Bob script. Thanks @Mutant Bob

the perpose of this script is to add a same amount of gap between all the clips or reduce the gap with same amount

Please select all the clips before running the script

import bpy

def gap_strips(strips, gap):
    strips = sorted(strips, key=lambda strip: strip.frame_start)

    if ( gap > 0 ):
        for i in range(len(strips)-1,0,-1):
            st1 = strips[i] 
            st1.frame_start = st1.frame_start + gap*i
    elif ( gap < 0 ):
        for i in range(0,len(strips)):
            st1 = strips[i] 
            st1.frame_start = st1.frame_start + gap*i
    elif ( gap == 0):
        for i in range(1,len(strips)):
            st0 = strips[i-1]
            st1 = strips[i] 
            print(st0.frame_start + st0.frame_final_duration,st1.frame_start)
            st1.frame_start = st0.frame_start + st0.frame_final_duration


def gap_selected_strips(scn, gap):
    gap_strips(
        [strip for strip in scn.sequence_editor.sequences if strip.select],
        gap)


gap_selected_strips(bpy.context.scene, 20)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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