Python basics help needed

I need some help with a few basic python topics.

  1. How can i test if a level exists?
    I tried this:
    unreal.EditorAssetLibrary.does_asset_exist(levelName)

    but i get the message:

“Warning: The AssetData ‘/Game/path/levelName.levelName’ exist but is not accessible because it is of type Map/Level.”

I need to run a function as part of a pipeline automation process…
if thisLevelExists:
unreal.LevelEditorSubsystem.set_current_level_by_name(levelName)
else:
thisLevel = unreal.LevelEditorSubsystem.new_level_from_template(levelName,templatelevel)

  1. How do you cast the object name from the path name?
    Unreal can’t do things because the functions expect object IDs not strings

    this_thing_asObject = unreal.what do I use here?

    I would like to write a python function that would return the object ID for all types of things: levels, assets, etc.

python
Editor Scripting
UnrealEngine 5.0.1

have you tried for assets:
unreal.EditorAssetLibrary.load_asset(“/game/path_to_my_asset_in_content_browser”)
for levels:
unreal.LevelEditorSubsystem.load_level()

1 Like