Movie Render Graph + python, How to set the Output directory

Is there a way in python to set the Render Output Directory for a job when using the movie render graph?

When we try the following operations, it toggles correctly the job override flag, but not the job override value:
1- In the Movie Render Graph Config Editor, Righlt-click on the node “Global Output Settings” and check “Expose Property as Pin” for “OutputDirectory”
2- Right-click on the pin “OutputDirectory”, click “Promote to Variable”. This creates the User Variable “OutputDirectory”
3- In the Movie Render Queue, create a render job, and use this Movie Render Graph Config asset (Replace with Graph, then select Graph asset)

4- Run the following code:

def test_UDN_ticket():
    def get_graph_config() -> unreal.MovieGraphConfig:
        mrg_pdpath = '/Game/Developers/sbinet/MRG_Test_by_script'
        mrg_pname = 'MRG_Graph_with_variables_Test'
        graph_config = unreal.load_asset(f'{mrg_pdpath}/{mrg_pname}')
        return graph_config

    def get_config_variable(graph_config: unreal.MovieGraphConfig, variable_name: str) -> unreal.MovieGraphVariable | None:
        for config_var in graph_config.get_variables():
            if config_var.get_member_name() == variable_name:
                return config_var
        return None

    queue_subsystem = unreal.get_editor_subsystem(unreal.MoviePipelineQueueSubsystem)
    graph_config = get_graph_config()
    existing_queue_job: list[unreal.MoviePipelineExecutorJob] = queue_subsystem.get_queue().get_jobs()[0]

    OutputDirectory_graph_variable = get_config_variable(graph_config, 'OutputDirectory')

    # Perform overrides at the job level
    job_override_variables = existing_queue_job.get_or_create_variable_overrides(graph_config)
    # The follwoing line has partially the expected effect: The checkbox is set, but the field stays grayed-out!!!
    job_override_variables.set_variable_assignment_enable_state(OutputDirectory_graph_variable, True)
    # This line does  not have any effet of the value.
    job_override_variables.set_value_serialized_string(OutputDirectory_graph_variable, str('C:'))

Result: The result is that in the Movie Render Queue, for the first job, the Primary Graph Variable name “Output Directory” shows the override checked, but the field for the value is still empty, and it is grayed-out!!!

Hi,

yeah, that method set_value_serialized_string is kinda misleading in this case. The output directory is of type unreal.DirectoryPath() and you need to set this type in serialized form.

In our scripts we’re setting the path using unreal.DirectoryPath('../outputdirectory').export_text() and that works for us.

your last line should be

job_override_variables.set_value_serialized_string(OutputDirectory_graph_variable, unreal.DirectoryPath('C:').export_text())

that should hopefully work for you.

Cheers

Thanks juanpb. It works fine when I apply your solution.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.