Download

Add sub LevelSequence track with python

Hi, I need to automate some steps that assemble the basis in Sequencer. Done manually, what I need to do is:

Double click a “MASTER” LevelSequence, to open it in Sequencer
Drag a second “Shot01” LevelSequence into the master sequence track.

That’s pretty much it but I need to automate it (preferably with python). I’ve managed to use the python API to assemble sub tracks like this:

masterSequenceAsset = unreal.LevelSequence.cast(unreal.load_asset(’/Game/Sequences/Intro/MASTER’))
masterTrack = masterSequenceAsset.get_master_tracks()[0]
newSubSection = masterTrack.add_section()
newSubSection.set_shot_display_name(‘MySubSection’)
newSubSection.set_row_index(1)
newSubSection.set_start_frame(1)
newSubSection.set_end_frame(100)

But this sub-track isn’t actually associated with the “Shot01"” LevelSequence as I need. Can anyone shed any light on this please?

Thanks in advance!

Answered this one myself, it seems that if you ensure the master track of the LevelSeqence is of type MovieSceneCinematicShotTrack, then the sections you add to it will be of type MovieSceneCinematicShotSection - which has a set_sequence method, that takes another LevelSequence as its arg.

masterTrack = masterLevelSequence.add_master_track(unreal.MovieSceneCinematicShotTrack)
section = masterTrack.add_section()
section.set_start_frame(1)
section.set_sequence(subLevelSequence)

https://docs.unrealengine.com/en-US/PythonAPI/class/MovieSceneCinematicShotSection.html
https://docs.unrealengine.com/en-US/PythonAPI/class/MovieSceneSubSection.html#unreal.MovieSceneSubSection