Attach metadata to actors from python

I’m trying to attach metadata to level actors using python. I came across a similar question (for 4.13 and C++) where the solution was to use ActorComponents for the job.
I’ve been introspecting the python stuff for hours now (4.22) and not gaining traction.

  • I’ve created a blueprint ActorComponent, with a member variable containing my property map
  • I’ve been able to attach them to the actor in the editor, using the (Add Component) button.
  • I’ve not been able to figure out how to create a component from Python, much less attach it to the actor.
  • For actors where I’ve manually added the component, I’ve not been able to get at it. the actor has a root_component member, but the blueprint actor component is not a child component of that.

For my use case (this is to support asset pipelines involving external assets and metadata) I need to be able to do this from a python script:

  1. Once I’ve called unreal.EditorLevelLibrary.spawn_actor_from_object() to create my static mesh actor, create some method to construct my component from the blueprint in /Game/ActorMetaData.
  2. Having access to the actor object in python, find the compoeent and inspect it / modify it.

Any thoughs?

Okay, I’ve been at this for a while now and I have found at least how to get at existing actor components, by looking at actor.get_components_by_class()
But I still have not been able to figure out how to create components and attach them to actors.
Not even using C++. I have a blueprint ActorComponent, at ‘Game/MetaDataComponent’ and would like to be able to instantiate such an object, with an actor as “outer”.
I know it is possible from blueprint scripts. I would be happy to create a BlueprintFunctionLIbrary to help me with this specific task. But even doing it from C++ is eluding me. I admit to having only limited experience with ue4 c++