How to create metadata curves for my morph targets?

Hi. I’m new to this editor scripting world. I figured out how to get the list of morph targets in a selected skeletal mesh. Now I can’t find a way to create the curve metadata for them. I’m trying to get the morph target names and loop through it adding a curve with the same name for each one.
I found some pieces of the puzzle here and there, but I can’t get it to work together.
Like I said, listing the morph targets was easy, 3 lines of code after days of research LOL.

I think it could be a really useful script, since there’s a lot of repetion in the curve-morph target setup for animations.

edit:
Found how to add curves trough

skeleton.find_curve_identifier(curve_name, curve_type)

The thing is, there’s no curve in my skeleton after that.

If you’re still looking, I couldn’t find any way in python or BP, but if you can do c++, the core part looks like this:

if (UAnimCurveMetaData* AnimCurveMetaData = SkeletalMesh->GetAssetUserData<UAnimCurveMetaData>())
	{
		// Process each parsed entry
		for (const FCurveMetaDataEntry& Entry : Entries)
		{
			FName CurveFName(*Entry.CurveName);
			
			AnimCurveMetaData->AddCurveMetaData(CurveFName);
			AnimCurveMetaData->SetCurveMetaDataBoneLinks(CurveFName, Entry.LinkedBones, Entry.MaxLOD, Skeleton);
			AnimCurveMetaData->SetCurveMetaDataMaterial(CurveFName, Entry.bMaterial);
			AnimCurveMetaData->SetCurveMetaDataMorphTarget(CurveFName, Entry.bMorphTarget);

			UE_LOG(LOG_CAT(), Log, TEXT("Added curve metadata for '%s'"), *Entry.CurveName);
		}

		// ReSharper disable once CppExpressionWithoutSideEffects
		SkeletalMesh->MarkPackageDirty();
		return true;
	}
	UE_LOG(LOG_CAT(), Warning, TEXT("PasteAnimCurves: SkeletalMesh has no AnimCurveMetaData asset user data"));
	return false;
}


FCurveMetaDataEntryis a just a struct type I made, but you can use these methods to programmatically add mesh curves just by using values from whatever source you had.

You can put this in a blueprint library and call it from bp or python like here: How To Expose C++ function to Python and Editor Utility Widgets | Knowledge base

If you’re getting into editor scripting, a lot of time you’ll find you can only do some things with c++.