No announcement yet.

Bug? SystemLibrary.execute_console_command not really working

  • Filter
  • Time
  • Show
Clear All
new posts

    Bug? SystemLibrary.execute_console_command not really working

    Hi, I'm developing a renderfarm plugin for Datasmith that starts many instances of unreal (4.21), and because of various other bugs it's become clear that I can't use UE4Editor-Cmd.exe to run it without a gui. I've worked around the issue for now, and have everything from my script working in the gui, but I need a way to close Unreal after the script has finished. My problem is that I can't seem to get the execute_console_command function to work at all.

    Am I doing this wrong? All of the following fail to produce anything for me:

    unreal.SystemLibrary.execute_console_command(unreal.EditorLevelLibrary.get_editor_world(), 'QUIT_EDITOR')
    unreal.SystemLibrary.execute_console_command(unreal.EditorLevelLibrary.get_all_level_actors()[0], 'QUIT_EDITOR')
    unreal.SystemLibrary.execute_console_command(unreal.EditorLevelLibrary.get_editor_world(), 'DumpConsoleCommands')
    unreal.SystemLibrary.execute_console_command(unreal.EditorLevelLibrary.get_editor_world(), 'rhi.DumpMemory')
    Last edited by MadisonAster; 12-12-2018, 07:26 PM.

    Good morning!

    Sadly, I don't know if it's a bug, but the function ExecuteConsoleCommand is not made to work outside of Play Mode. (Which is sad)
    The reason it does not work: The function passes through the Player Controller to execute the command.
    In my opinion, the function should not be available in Python, but Python has everything that Blueprint has, so this is why we see it.

    I tried to find a Python workaround, but I was not able.

    Here is a C++ function that does exactly what you need:

    void UCppLib::ExecuteConsoleCommandEditor(FString Cmd) {
        if (GEditor) {
            UWorld* World = GEditor->GetEditorWorldContext().World();
            if (World) {
                GEditor->Exec(World, *Cmd, *GLog);
    Have An Awesome And Productive Day
    Alex, Youtube Tutorials