Create BP class from C++ Code

If have Plugin with editor extension which create BP class based on my custom ACharacterActor class.



void FECSPluginModule::ConvertToMesh(UDebugSkelMeshComponent* PreviewComponent)
{
      UBlueprint* Blueprint = FKismetEditorUtilities::CreateBlueprintFromClass(FText::FromString(TEXT("CreateNewBlueprint")),ACharacterActor::StaticClass(),TEXT("CharacterBP"));
}


And i want get my ACharacterActor class of this created blueprint and set some values of this class. And when Blueprint will be created as assets values will be already set. Because ill set some values data from PreviewComponent. Is it possible ? Or should i create ACharacterActor first and then create blue print based on ACharacterActor class instance with set values?

Also this test code crash when im open created BluePrint




void FECSPluginModule::ConvertToMesh(UDebugSkelMeshComponent* PreviewComponent)
{
      ACharacterActor* charActor;
      UBlueprint* Blueprint = FKismetEditorUtilities::CreateBlueprintFromClass(FText::FromString(TEXT("CreateNewBlueprint")),ACharacterActor::StaticClass(),TEXT("CharacterBP"));
      charActor = (ACharacterActor*)Blueprint->SimpleConstructionScript->GetOwnerClass();
      UE_LOG(LogTemp, Warning, TEXT("Class = %s"), *charActor->GetName()); charActor->TestINT = 159;
}