Timeline - generate track/clips from assets by name via script

Hello, I’m working on a cinematic with timeline tools and have some shots with around 20 characters and mocap data that needs to be attached to them.
I decided to make a game object per shot, with all the instances of the characters, and than make a timeline with all needed animations. Finally those timelines would be nested in a master timeline with Cinemachine and what not.
Now - I have all animations per shot named and arranged in my Assets folder, and I made a script that creates the root game object and the required number of instances. It also creates the timeline, and a track for each character, bound to the respective animator. The only thing I can’t figure out is how to create the clips in the timeline. I got the names of the animations like this:
string[ ] anims = AssetDatabase.FindAssets(wildcard);
and managed to create empty dummy clips like so:

            AnimationClip clip = new AnimationClip();
            AnimationPlayableOutput output = AnimationPlayableOutput.Create(graph, clip.name, tmp.GetComponent<Animator>());
            AnimationClipPlayable playable = AnimationClipPlayable.Create(graph, clip);
            output.SetSourcePlayable(playable);

            TimelineClip timelineClip = track.CreateClip(clip);
            timelineClip.duration = clip.averageDuration;
            timelineClip.displayName = clip.name;

So how do you create AnimationClip from asset path?
Note: the script is not intended to run in game mode, only in the Editor, to automate this task.

Ok, it turns out it’s way easier when you got few hours of sleep :slight_smile:
AnimationClip clip = (AnimationClip)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(anim),typeof(AnimationClip));