Add StaticMesh to Blueprint from a Plugin in the Editor

Hey guys,

can anybody give me a hint on how to add a StaticMesh to a Blueprint.

I create a Blueprint in the ContentBrowser on import of an Asset and want to insert the imported Mesh into the created Blueprint. All done in code. Creating a custom import pipeline.

Thanks in advance!

I figured it out.

This example is within a OnAssetPostImport callback.

// get component for blueprint depending on the assettype
TSubclassOf<UActorComponent> componentClassForAsset = FComponentAssetBrokerage::GetPrimaryComponentForAsset(uObject->GetClass());
// create name of node
const FName nodeName = FName(*FComponentEditorUtils::GenerateValidVariableNameFromAsset(uObject, nullptr));
// create blueprint node
USCS_Node* newNode = _blueprint->SimpleConstructionScript->CreateNode(componentClassForAsset, FName(nodeName));
// link the asset to the component
FComponentAssetBrokerage::AssignAssetToComponent(newNode->ComponentTemplate, uObject);
// add the created node to the root node of the blueprint