0
$\begingroup$

This may be a two-fold question, but I think I got an answer on the first:

In order to keep the strain of running an "detect updates" function, as low as possible, I would like to make it as streamlined as possible. But there doesn't seem to be an equivalent to ex. "bpy.data.movieclips.is_updated" (for the motion tracker clip) for the sequencer?https://docs.blender.org/api/blender_python_api_2_76_0/bpy.types.BlendData.html

So I guess the only way is to compare the currently active strip's data with the data of a previous active strip, on scene updates, but how do I do that?

import bpy 
from bpy.app.handlers import persistent

oldStrip = bpy.context.scene.sequence_editor.active_strip  

def sequencer_update(context):
    #if bpy.data.movieclips.is_updated: # Updates on tracker file updates, but no sequencer .is_updated function? 

        global oldStrip
        activeStrip = bpy.context.scene.sequence_editor.active_strip
        print("Active strip: "+str(activeStrip.name))
        if oldStrip != activeStrip: # 
            if oldStrip.name == activeStrip.name:
                if oldStrip.frame_final_start == activeStrip.frame_final_start and oldStrip.frame_final_end == activeStrip.frame_final_end:
                    print("Strip not moved, maybe a rename or other property changes?")
                if oldStrip.frame_final_start != activeStrip.frame_final_start and oldStrip.frame_final_end != activeStrip.frame_final_end:
                    print("Entire strip moved")
                if oldStrip.frame_final_start != activeStrip.frame_final_start and oldStrip.frame_final_end == activeStrip.frame_final_end: 
                    print("Start handle moved")
                    bpy.context.scene.frame_set(sequence.frame_final_start) # move time cursor
                if oldStrip.frame_final_start == activeStrip.frame_final_start and oldStrip.frame_final_end != activeStrip.frame_final_end:
                    print("End handle moved")
                    bpy.context.scene.frame_set(sequence.frame_final_start)# move time cursor                        
            else:
                print("New strip selected")    
        oldStrip = activeStrip
#Register 
def register():

    handlers = bpy.app.handlers.scene_update_pre
    for handler in handlers:
        if ("sequencer_update" in str(handler)):
            handlers.remove(handler)
    handlers.append(sequencer_update)

def unregister():
    handlers = bpy.app.handlers.scene_update_pre
    for handler in handlers:
        if ("sequencer_update" in str(handler)):
            handlers.remove(handler)

    #Unregister operators
    bpy.utils.unregister_module(__name__)

if __name__ == "__main__":
    register()

unregister()
$\endgroup$
4
  • $\begingroup$ My hope is to make an add on to update the preview when trimming in the Sequencer. Though it might slow down, for me, it makes no sense to trim without seeing what frames you're trimming. $\endgroup$
    – tintwotin
    Commented Dec 19, 2017 at 23:14
  • $\begingroup$ I would like to lock the play-head(time cursor) to the handle of a strip when it is trimmed, so the actual trim frame is visible and updated. Like this: youtube.com/edit?o=U&video_id=ESdlSVqdrvU but I need to detect when something has been changed in the Sequencer. The only way to detect this is by comparing the previous active strip with the current active strip(I guess). The previous active strip must be defined before the update function is called and that's the reason for the need for having the previous scene data as a global variable. $\endgroup$
    – tintwotin
    Commented Dec 20, 2017 at 17:10
  • $\begingroup$ Sorry, like this: m.youtube.com/watch?v=ESdlSVqdrvU $\endgroup$
    – tintwotin
    Commented Dec 20, 2017 at 17:55
  • $\begingroup$ Consider using a set up like this, which runs a modal timer activated by a boolean property switch On global see second part of this answer $\endgroup$
    – batFINGER
    Commented Dec 23, 2017 at 10:21

0

You must log in to answer this question.

Browse other questions tagged .