Is it possible to create a Blueprint Graph with code?

Hello, I am working on an custom importer for UE5.4.

The importer deals with files that contain information about an object’s behaviour. I need to translate it into a blueprint.

I cannot simply write a C++ class with methods. I need to be able to visualize and modify the graph after its creation.

Is it possible, with either Python scripts or C++ code, to create a Blueprint class and set up its graph?

Thanks a lot in advance for your responses and your time.

No, you can call certain C++ functions from blueprints and vice versa, though it is not possible to visualize a C++ code or any other text by auto creating and connecting nodes with the engine. It is also not possible to adjust the blueprint code while the program is running. By not possible, I of course mean that with my current knowledge but I highly doubt there’s a plugin that allows you to do that. I’m not an expert but I guess any interference to that would contradict with the engine’s compiling system.

Using C++ you can create a new blueprint, then add and edit graphs in it.
You will need the following functions:

FBlueprintEditorUtils::CreateNewGraph
FBlueprintEditorUtils::AddUbergraphPage
FGraphNodeCreator< UNodeClass >::CreateNode
UEdGraph::AddNode
UEdGraphNode::FindPin->MakeLinkTo

Also don’t forget to notify blueprint about change and compile it.
FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified
FBlueprintEditor::Compile

EDIT:
@PREDALIEN answered as I typed this. His solutions seems perfect.

Thanks for the fast response.

I already have a plugin that adds a toolbar button that when clicked creates an empty Blueprint class:

Here is the PluginButtonClicked() method:

void FToolbar_Btn_PluginModule::PluginButtonClicked()
{
	// Generate a new name (Ex: BP_Generated_017)
	FString BP_Name = std::format("BP_Generated_{:0{}}", ++i, 3).c_str();
	FString BP_Path = "/Game/Blueprints/" + BP_Name;

	// Create a new Package
	UPackage* Package = CreatePackage(*BP_Path);

	// Create and init a new Blueprint
	UBlueprint* Blueprint = FKismetEditorUtilities::CreateBlueprint(
		AActor::StaticClass(),
		Package,
		*BP_Name,
		BPTYPE_Normal,
		UBlueprint::StaticClass(),
		UBlueprintGeneratedClass::StaticClass()
	);

	if (Blueprint)
	{
		// Notify the asset registry
		FAssetRegistryModule::AssetCreated(Blueprint);

		// Mark the package dirty...
		Package->MarkPackageDirty();
	}
}

Is there any way to add Nodes to the graph of such a Blueprint?

Thanks, this looks exactly like what I need.
I’ll try it out and check that I can make it work.

I’m not familiar with that plugin. I might have misunderstood your objective btw, I thought you were looking for some auto generation stuff. That was the topic I was so confident on, but sure there might be ways to do that through text.