# Populate Level Blueprint Using Python?

**URL:** <https://forums.unrealengine.com/t/populate-level-blueprint-using-python/152374>\
**Category:** Editor Scripting\
**Tags:** unreal-engine\
**Created:** [October 19, 2020, 3:57pm UTC](https://forums.unrealengine.com/t/populate-level-blueprint-using-python/152374 "2020-10-19T15:57:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AtomicPerception](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AtomicPerception](https://forums.unrealengine.com/u/AtomicPerception)\
**Post date:** [October 19, 2020, 3:57pm UTC](https://forums.unrealengine.com/t/populate-level-blueprint-using-python/152374/1 "2020-10-19T15:57:02Z")

</div>

I am trying to write some python code that will generate the following three node event trigger inside the Level Blueprint. This setup auto plays a MediaPlayer.  
Does anyone have any python code to demonstrate this type of Unreal Editor Scripting?

---

<div class="post-metadata">

**Author:** ![AtomicPerception](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@AtomicPerception](https://forums.unrealengine.com/u/AtomicPerception)\
**Post date:** [October 26, 2020, 3:15am UTC](https://forums.unrealengine.com/t/populate-level-blueprint-using-python/152374/2 "2020-10-26T03:15:06Z")

</div>

Here is a partial solution suggested on the discord. Instead of constructing the blue using python, create the blueprint as an asset and load a copy for modification.

```auto

import unreal

ell = unreal.EditorLevelLibrary
eal = unreal.EditorAssetLibrary

# Load my pre-created blueprint.
bp_temp = eal.load_asset("Blueprint'/Game/AutoPlayFootage/BP_AutoPlayFootage.BP_AutoPlayFootage'")
bp_gc = eal.load_blueprint_class(bp_temp.get_path_name())

bp_actor = ell.spawn_actor_from_class(bp_gc, unreal.Vector(0,0,0), unreal.Rotator(0,0,0))

# Load my pre-created media player.
MP_asset = eal.load_asset("MediaPlayer'/Game/NewMediaPlayer.NewMediaPlayer'")

# Try to assign to existing variable inside of pre-created blueprint.
bp_actor.set_actor_label('FootageAutoPlay')

# Make sure this property is set to public inside the blueprint.
bp_actor.set_editor_property("varMediaPlayer1", MP_asset)

```

---

<div class="post-metadata">

**Author:** ![joric](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/joric/32/749440_2.png) [@joric](https://forums.unrealengine.com/u/joric)\
**Post date:** [September 28, 2023, 8:07pm UTC](https://forums.unrealengine.com/t/populate-level-blueprint-using-python/152374/3 "2023-09-28T20:07:28Z")

</div>

I was getting warnings like “Warning: TryConvertFilenameToLongPackageName was passed an ObjectPath rather than a PackageName or FilePath. Accepting ObjectPaths is deprecated behavior and will be removed in a future release; TryConvertFilenameToLongPackageName will fail on ObjectPaths”.

So I used eal.load\_asset(“/Game/Items/BP\_Item”).get\_outer().get\_full\_name() to get rid of them.

Now I am wondering if it’s possible to move item to a specific folder to organize them within a level. Can’t find API about that.
