Use Python to set a Camera Cut Track to be locked to the viewport

I’ve got a level sequence with a camera cut track and a lot of cameras and would like to have a function in a python script to set the camera cut track to be active (controlling the viewport) and another to set one of the other cameras to be active. Is this possible in python? I can’t find a command that controls what camera the current viewport is using.

Failing that, if there’s at least a way to select the camera cut track in the level sequencer then I could just hit the button myself, but for selection all I’ve found is…

    unreal.EditorLevelLibrary.set_selected_level_actors(   )

That works with the real cameras, but not the camera cut track as it doesn’t work with the class MovieSceneCameraCutTrack.

I eventually figured out a way to select the camera cut track, for any who needs it:

sequence = unreal.LevelSequenceEditorBlueprintLibrary.get_current_level_sequence()
FrameRate =  float( sequence.get_display_rate().numerator / sequence.get_display_rate().denominator)

all_tracks = sequence.get_master_tracks()
CameraCutTrack = None
for Track in all_tracks:
    if str(Track).count("MovieSceneCameraCutTrack"):
        CameraCutTrack = Track
if CameraCutTrack != None:
    unreal.LevelSequenceEditorBlueprintLibrary.empty_selection()
    unreal.LevelSequenceEditorBlueprintLibrary.select_tracks([CameraCutTrack])

and the command to lock the camera cut track to the viewport is:

unreal.LevelSequenceEditorBlueprintLibrary.set_lock_camera_cut_to_viewport(True)

1 Like