In the Unreal Editor, if I click on a static mesh actor and go to File > Export Selected
, a dialog opens. Say I give it a filename like "blah.obj"
.
A new dialog opens that says
"Would you like to export the materials as images (slower)?"
Yes, No, Cancel
I click on No, and it does exactly what I want.
Now I’m trying to mimic this behavior from python. The following script, gets me close, but I cannot suppress the “yes, no, cancel dialog” with an option that I want - in my case, I want to select no.
Here’s the script
def export_selected(obj_file: str, automated: bool):
"""
Export the selected asset to an obj file, mimicking `File > Export Selected`.
"""
world = unreal.get_editor_subsystem(unreal.UnrealEditorSubsystem).get_editor_world()
exporter = unreal.LevelExporterOBJ()
task = unreal.AssetExportTask()
task.selected = True
task.filename = obj_file
task.object = world
task.exporter = exporter
task.replace_identical = True
if automated:
task.automated = True
task.prompt = True
result = exporter.run_asset_export_task(task)
If I set automated=True
, then the dialog does not open, but it selects yes. I want it to select no.
Any ideas?