Create animation asset from C++ or Python

I’m working on a motion capture system. I’m starting to make a plugin for UE4/UE5 and wanting to allow import of motion capture data into Unreal, onto MetaHumans. I want to allow the user to click on a target MetaHuman, and allow selection of a recording to import. At that point a script will run to process our custom retargeting from the tracking data onto the extracted skeleton. That part already works. I need to be able to create something that will drive the animation of the MetaHuman e.g. an animation asset with curves containing our custom-retargeted rotation sequence.

Is this possible? My Google-foo is failing me.

Thanks in advance.

OK, I can create the asset from Python by doing the following:

def create_anim_asset(path: str, props: Dict[str, Any] = None) -> unreal.AnimSequence:
    """
    Creates an animation asset at the given path.
    :param path: Path to create the asset at.
    :param props: Editor properties to set on the asset. See print_all_properties() for a list of properties.
    :return: The created animation asset.
    """
    parts = pathlib.PurePosixPath(path).parts
    folder = str(pathlib.PurePosixPath(*parts[:-1]))
    name = parts[-1]
    factory = unreal.AnimSequenceFactory()
    obj = assets_tools.create_asset(name, folder, None, factory)
    if obj is None:
        raise RuntimeError(f'Failed to create asset at {path}')
    if props is not None:
        for k, v in props.items():
            obj.set_editor_property(k, v)
    assets.save_loaded_asset(obj)
    # noinspection PyTypeChecker
    return obj

Now, I want to set the ‘Skeleton’ property, but that property is read-only e.g. if I call

create_anim_asset('/Game/MyFolder/my_anim_name, props={'Skeleton': my_skeleton})

then I get the error:

Exception: AnimSequence: Property 'Skeleton' for attribute 'Skeleton' on 'AnimSequence' is read-only and cannot be set

Trying to open the animation within the content browser brings a popup saying that there is no skeleton, and would I like to select one. So the property is not really read-only, it is just that way from Python.

Any hints on what to do next?

Never mind, did it by making a C++ class that does the parts that cannot currently be done from Python, then call that class from Python e.g. unreal.MyPluginName.anim_set_skeleton(). As you were everyone.