Download

Populate Level Blueprint Using Python?

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?

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.



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)