Could add a sub-level to current level with python?

Here is a function called : create_new_streaming_level

in unreal.EditorLevelUtils — Unreal Python 4.27 (Experimental) documentation

But could create a sub-level by existing level?

Hi there.
Yeah, that’s possible.
Use the following format (Change the level_path with your level path of the level you would like to add):

level_path = "/Game/Maps/Test"
unreal.EditorLevelUtils.create_new_streaming_level(unreal.LevelStreaming, new_level_path = level_path)

Using this function would create a new level, couldn’t using existing level

  1. should open this level , or engine will crash

2.using unreal.EditorLevelUtils.add_level_to_world to add existing level

tarLevelPath = "/Game/Maps/Test"
unreal.EditorLoadingAndSavingUtils.load_map(sourLevel.get_path_name())
world = unreal.EditorLevelLibrary.get_editor_world()
ue.EditorLevelUtils.add_level_to_world(world,tarLevelPath,unreal.LevelStreamingAlwaysLoaded)
ue.EditorLevelLibrary.save_current_level()

could use unreal.LevelStreamingDynamic instead unreal.LevelStreamingAlwaysLoaded

Hello, anyone knows how to remove a level in the current scene instead? I’m new here so I hope it’s ok to ask on this post, thanks in advance