How to retrieve the Level Object using Python API

Hi ,
I want to script the static light building of my project ( blueprint only ) which has close to 30 sub-levels in UE 4.22.3. Currently, I am manually turning on and off each level and building it individually which is quite painful as the levels take time to build. I want to script the following sequence : 1) Turn on first sub-level 2) Build 3) Save 4) Turn off first sub-level and turn on second sub-level 5) Build & so on.

I see the python API unreal.EditorLevelUtils.set_level_visibility needs a Level object as an argument but I can’t find any API that returns a Level object . I have tried using find_asset but it returns "world’ object and set_level_visibility(…) fails. Here is what I tried out :


LogPython: level_path = '/Game/New_Maps/Bridge_V3.Bridge_V3'
LogPython: level = unreal.find_asset(name=level_path)
LogPython: print level
LogPython: Object '/Game/New_Maps/Bridge_V3.Bridge_V3' (0x000002CCB9BD5600) Class 'World'


Can somebody tell me how I can retrieve the Level object ? Thanks in advance.