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.
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.
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.
@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.
Ah sorry, it is working 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.
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.