Download

Python, adding Level sequence in Master Sequence.


master_sequence = unreal.AssetToolsHelpers.get_asset_tools().create_asset(asset_name=master_sequence_name, package_path=path, asset_class=unreal.LevelSequence, factory=unreal.LevelSequenceFactoryNew())

shot = unreal.AssetToolsHelpers.get_asset_tools().create_asset(asset_name=shot_name, package_path=path, asset_class=unreal.LevelSequence, factory=unreal.LevelSequenceFactoryNew())

Hi I wouldn’t say I’m an expert at setting up Sequencer manually but I can manage to get something together. I’m trying to automate adding a shot into a master sequence via python. I’m not sure how to go about doing this. I see in the docs about adding a master track, but I’m not sure how unreal.MovieSceneSequence fits into this. unreal.MovieSceneSequence — Unreal Python 4.26 (Experimental) documentation

Thanks in advance!

I’m a beginner when it comes to Python, but I think I can help out.

unreal.MovieSceneSequence is the base class for the unreal.LevelSequence class. So the level sequences you created in your code will share properties with unreal.MovieSceneSequence.

Using your existing code, adding a MovieSceneCinematicShotTrack and a section to that track will look something like this:




master_sequence = unreal.AssetToolsHelpers.get_asset_tools().create_asset(asset_name=master_sequence_name, package_path=path, asset_class=unreal.LevelSequence, factory=unreal.LevelSequenceFactoryNew())

shot = unreal.AssetToolsHelpers.get_asset_tools().create_asset(asset_name=shot_name, package_path=path, asset_class=unreal.LevelSequence, factory=unreal.LevelSequenceFactoryNew())

# add MovieSceneCinematicShotTrack track to your master_sequence
shotsTrack = master_sequence.add_master_track(unreal.MovieSceneCinematicShotTrack)
# add a section to the track
section = shotsTrack.add_section()
# add your shot sequence to the section
section.set_editor_property('sub_sequence', shot)
# set other properties on the section such as end frame
section.set_end_frame(50)



You can find the section reference here unreal.MovieSceneCinematicShotSection — Unreal Python 4.27 (Experimental) documentation and here unreal.MovieSceneSection — Unreal Python 4.27 (Experimental) documentation

Thanks for the reference links and examples pmonga. I’ll give that a shot!

Also, there’s some python examples in the source here:

Engine\Plugins\MovieScene\SequencerScripting\Content\Python\sequencer_examples.py

Missed that somehow. Thank you, that helps a lot.