Execute shortcut loop?

I’m trying to execute a shortcut on multiple segments. When this runs… I can see flame hitting the button multiple times on the first segment and not going to the next segment. Any idea what I’m missing? In my for loop I think it should hit the execute_shortcut and then go back up to find and select the next segment.

def update_burnin(selection):
    import flame
    for shot in selection:
        for version in shot.versions:
            for track in version.tracks:
                for segment in track.segments:
                    for tlfx in segment.effects:
                        if tlfx.type == 'Burn-in Metadata':
                            segment.selected = True
                            flame.execute_shortcut ("Update (Button)")

doing
segment.selected = True
adds to the selection but does not change the “current” segment, so instead try doing
shot.selected_segments = [segment]

If you have more then one “shot” in selection. You may need to open them as sequence or do a similar gymnastic with the flame.media_panel.selected_entries if the visible timeline is the “source” timeline.

Thanks Philippe. That makes sense. I have multiple sequences and they are all ‘open’ before trying the hook. It doesn’t appear to go to the next sequence.

In each sequence there is only one segment with Burn-In Metadata effect and that is the only soft effect on the segment And they are all named the same so I wonder if I should try to select that segment in each sequence by name.

execute_shortcut is a nice workaround for things missing in the python api but still a workaround. It execute the shortcut just like you had done it yourself, so if the currenlty shown sequence in the timeline is not change it will execute it over the same sequence. Opening the shot as sequence (even if it already an opened sequence ) before your version loop should make it the sequence displayed in the timeline.

ah nice. I’ll work on that.

try something like

def update_burnin(selection):
    import flame
    for shot in selection:
        shotname = shot.name.get_value()
        try:
            shot = shot.open_as_sequence()
            for version in shot.versions:
                for track in version.tracks:
                    for segment in track.segments:
                        for tlfx in segment.effects:
                            if tlfx.type == 'Burn-in Metadata':
                                shot.selected_segments = [segment]
                                flame.execute_shortcut ("Update (Button)")
        except:
            print("Had issues with %s"%(shotname))

The try-except will insure that if an error occur on a clip ( lock clip or segment ), the script will still continue to execute with the next clip.

1 Like

This is perfect Philippe! Worked right away.

Thanks
Bryan