Getting all selected nodes in the active (blueprint) editor graph

The past couple days I have been trying to find a way to get the selected nodes in the blueprint editor graph, but I’m stuck at getting the current active graph. I have looked in various classes like FBlueprintEditor, SGraphEditor, etc. and followed function calls but I didn’t get very far.

Any help would be much appreciated!

Figured it out with the help of another thread:

	TArray<UObject*> EditedAssets = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->GetAllEditedAssets();

	for (UObject* Asset : EditedAssets)
	{
		IAssetEditorInstance* AssetEditorInstance = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->FindEditorForAsset(Asset, false);
		FAssetEditorToolkit* AssetEditorToolkit = static_cast<FAssetEditorToolkit*>(AssetEditorInstance);

		TSharedPtr<SDockTab> Tab = AssetEditorToolkit->GetTabManager()->GetOwnerTab();
		if (Tab->IsForeground())
		{
			FBlueprintEditor* BlueprintEditor = static_cast<FBlueprintEditor*>(AssetEditorToolkit);
			FGraphPanelSelectionSet SelectedNodes = BlueprintEditor->GetSelectedNodes();
		}
	}
1 Like