Basic python help - move clips to timeline

Hi all, trying to write a simple python script to overwrite clips onto a timeline, and could use some pointers.

These are source clips which will normally have source TC which matches timeline rec TC.

The aim is to:

  • select one or more clips in library
  • fetch start TC from each
  • move current record timeline playhead to same TC
  • overwrite on current primary track
  • loop to end of selection

I can successfully fetch the start TC from source clip using item.start_time.

Then I need to switch focus to the record timeline - to remove any existing in/out marks and move the playhead to the source TC equivalent - before performing the overwrite. But I can’t find a way to switch focus, so any flame.timeline or flame.current_sequence functions seem just to apply to the selected source clip timeline (loaded on the green tab), not to the recored timeline (red tab). Any ideas?

The only way I can see to perform the overwrite function is using flame.execute_shortcut("Overwrite Edit") but is there a cleaner way?

Of course there may be an entirely different and better way to approach this.

TIA!

There may be a more elegant way but one thing that came to mind was to use selection order. Select the record sequence first, then all the source clips, and store the first item in your selection as a variable that you can do timeline operations on. I just tested and flame.media_panel.selected_entries and the selection tuple that gets passed from the get_media_panel_custom_ui_actions() hook both respect selection order.

1 Like

This will do what you’re after, Just select the clips in the media panel and it will add them to the current sequence using source tc, doesn’t have any ability to deal with multiple clips with the same tc so will overwrite the last selected.

Auto Sequence.zip (3.0 KB)

2 Likes

@dazedinheaven Thanks for this great idea, I’ll explore it further.

@Jason_Chambers Thanks very much for taking the time to write this. It prints the expected info correctly, but unfortunately doesn’t actually perform an edit. It doesn’t throw an error, so I’m trying to work out why not.

It’s a tried and tested one so should work, check video is patched and the sequence is open.

Ah sorry, it is working :slightly_smiling_face: I hadn’t realised it’s actually overwriting into whichever sequence is listed first in the library, irrespective of whether it’s open or not. So hopefully I’ll be able to manipulate that to work just on the current active sequence instead.

Thanks again!

Still stuck on this sequence thing. Sorry I realise this is basic stuff.

So flame.project.current_project.current_workspace.libraries[0].sequences[0] writes to the first sequence in the first library. How do I identify the current active record sequence, irrespective of where it sits in the libraries?

flame.project.current_project.current_sequence doesn’t seem to work.

flame.timeline.clip will return the PyClip/PySequence currently viewed in the timeline.

MasterSequence = flame.timeline.clip

The timeline could be showing the active sequence, current source clip, or an open container.

If you want to insure the timeline is showing the active sequence, you can do

flame.timeline.type = “sequence”
MasterSequence = flame.timeline.clip
2 Likes

Thank you @PhilippeJ - I would never have got to that