How to exclude certain shots from a MRQ rendering via python

I am rendering out a sequence using movie render queue via python. It renders out fine with the exception of being able to tell it which shots in the MovieSceneCinematicShotTrack. Here is what I am doing:

`MPQ = unreal.get_editor_subsystem(unreal.MoviePipelineQueueSubsystem)
LES = unreal.get_editor_subsystem(unreal.LevelEditorSubsystem)

seq_name = “MySequence”
seq_path = “/Game/blah/de/blah/MySequence”
preset_path = “/Game/blah/de/blah/MyPreset”

Load up the sequence and preset assets

seq_asset = ESS.load_asset(seq_path)
preset_asset = ESS.load_asset(preset_path)

Load up the requested level

LES.load_level(level_path)

Empty the queue - one render at a time

queue = MPQ.get_queue()
queue.delete_all_jobs()

Create the job

job = queue.allocate_new_job()
job.map = unreal.SoftObjectPath(level_path)
job.sequence = unreal.SoftObjectPath(seq_path)
job.set_configuration(preset_asset)

Build a list of shots to enable/disable (render only first)

job.shot_info = unreal.Array(unreal.MoviePipelineExecutorShot)
tracks = seq_asset.find_tracks_by_exact_type(unreal.MovieSceneCinematicShotTrack)
if shots and tracks:
sections = tracks[0].get_sections()
First_Shot = True
for shot_section in sections:
shot_executor = unreal.MoviePipelineExecutorShot()
shot_executor.enabled = First_Shot
shot_executor.outer_name = shot_section.get_name()
job.shot_info.append(shot_executor)
First_Shot = False

Set up any custom configuration values not controlled through the preset

config = job.get_configuration()

Exports

config.find_or_add_setting_by_class(unreal.MoviePipelineImageSequenceOutput_JPG)

Rendering

config.find_or_add_setting_by_class(unreal.MoviePipelineDeferredPassBase)

Settings

output_setting = config.find_or_add_setting_by_class(unreal.MoviePipelineOutputSetting)
output_setting.output_directory = unreal.DirectoryPath(render_path)
output_setting.flush_disk_writes_per_shot = True
output_setting.use_custom_frame_rate = True
output_setting.output_frame_rate = unreal.FrameRate(30)
output_setting.file_name_format = seq_name + “.{frame_number}”

Submit render job

executor = unreal.MoviePipelinePIEExecutor(MPQ)
MPQ.render_queue_with_executor_instance(executor)`Notice that I have a loop that creates the Array of MoviePipelineExecutorShot that have the enable flag set. For this test I told it to set the first shot to true and all following shots to false. I’m passing the name of the section, as the docs indicate, but in the end every single shot renders. None are skipped.

What am I doing wrong there?

Hi Tom,

What’s happening there is that the “shot_info” array is generated internally when you set the job’s sequence, and then regenerated internally when the executor runs, overriding your attempt at customizing its settings.

This second regeneration of the “shot_info” array is unfortunately necessary on the current implementation. The good news is that it does attempt to keep the “enabled” flag previously set on each MoviePipelineExecutorShot. However, for this to work, the shots must be in the expected order and both their “inner_name” and “outer_name” must match the expected values. The easiest way to guarantee this is to keep the original “shot_info” array unaltered, with the exception of the “enabled” flags. Here’s an example that should work:

`# Get the movie render queue and empty it
queue = MPQ.get_queue()
queue.delete_all_jobs()

Create our job and set it up with the level, level sequence, and preset assets

job = queue.allocate_new_job()
job.map = unreal.SoftObjectPath(level_path)
job.sequence = unreal.SoftObjectPath(seq_path)
job.set_configuration(preset_asset)

Build a list of shots to enable/disable (render only first)

First_Shot = True
for shot_info in job.shot_info:
shot_info.enabled = First_Shot
First_Shot = False`Alternatively, if you find it easier to iterate over the MovieSceneCinematicShotSection objects, you can backup their “is_active” editor property and set it as needed before rendering. This also allows you to control which ones should be rendered. After rendering is done, you can restore that property from the backup.

I hope this is helpful. Please let me know if one of these approaches work for you.

Best regards,

Vitor

Thanks. This worked like a charm.