GDQuest / blender-power-sequencer

Add-on for video editing in Blender 3D: edit videos faster! Included in Blender 2.81+
https://gdquest.com/blender/power-sequencer/
GNU General Public License v3.0
717 stars 58 forks source link

Ripple support to smart snap added #336

Closed guilhermehto closed 5 years ago

guilhermehto commented 5 years ago

The ripple works only on sequences that are in the same line as the selected ones. To use it, press shift along with the other keys.

219 also asks for remove gaps, but I'm not sure how to go about it because of the shortcuts:

This leaves us out of modifier keys to add.

Suggestions are welcome.

If remove gaps is not needed anymore, this PR closes #219

guilhermehto commented 5 years ago

@NathanLovato should be good now 🙂

NathanLovato commented 5 years ago

There's a little bug with effect strips left, but besides it's working now. I'll merge and patch now. Thanks!

NathanLovato commented 5 years ago

A quick note on using if statements to check and run code: a rule in python is that it's best to ask for forgiveness than permission. You can often use try/except to run code that should work most of the time and handle exceptional cases.

In the example below, there are only 2 cases taken in account. Quite a few possible edge cases that'll trigger errors:

            if s == sequence and side == 'LEFT':
                s.frame_start -= gap
                continue
            if sequence.frame_final_end < s.frame_final_start:
                s.frame_start -= gap

You can use try to let Python handle these for you:

            if s == sequence and side == 'LEFT' or sequence.frame_final_end < s.frame_final_start:
                try:
                    s.frame_start -= gap
                except AttributeError: # Pass for any strip that doesn't have the frame_start attribute
                    continue

I didn't use it enough in the past, but it's a super convenient feature.