Accessing the Merge Actors tool from an editor utility blueprint

Context:
I currently have a reasonably high amount of actors that are constructed using spline mesh actors. However at run time this leads to a more draw calls than I’d like.

As such my currently planned approach is to Merge these actors into new static meshes that are generated in a specific level via an editor utility blueprint and to then use an HISM to render them.

As we’re currently talking ~200 actors that each need to be merged, I’d like to do a batch operation to merge and name all these actors/meshes correctly.

Question:
I’m currently struggling to find a way to access the merge tool from an editor utility blueprint. Is this even possible?

I’m not super experienced with the CPP side of things, however willing to dip my toes in if it’s as simple as just creating something to expose the menu event. Although currently not even sure where to start looking.

Ideally I’d like to write a script to just automate the process, in case I need to tweak the assets and re-generate them.

I’m Also working on this, for now I’m rewriting RunMerge in my API.
But to do this I need to include that:

  • include <MergeActors/Private/MergeActorsTool.h>
  • include <MergeActors/Private/MeshMergingTool/MeshMergingTool.h>
    But those are private files so I’m not sure how to proceed.
    I’m stuck after adding “MergeActors” to PrivateDependencyModuleNames in Build.cs

I managed to run the MergeActorsTool from a C++ file in a custom game module in Unreal Engine 5.3.2 by adding “MergeActors” to my Module’s Build.cs file under PrivateDependencyModuleNames. Once I change something in my Build.cs files, I usually like to regenerate my project’s solution; it’s a habit I picked up long ago over some error I stumbled upon way back when I don’t even remember in detail. So I did that, although you might not need to do that. From there, you can then import the headers without explicitly offering their paths:

#include "IMergeActorsModule.h"
#include "IMergeActorsTool.h"

Then I just load the module and get the tools that are registered in the module.

TArray<IMergeActorsTool*> MergeActorsTools;
IMergeActorsModule& MergeActorsModule = FModuleManager::Get().LoadModuleChecked<IMergeActorsModule>("MergeActors");
MergeActorsModule.GetRegisteredMergeActorsTools(MergeActorsTools);
check(MergeActorsTools.Num() > 0);
IMergeActorsTool* MergeActorTool = nullptr;
for (IMergeActorsTool* Tool : MergeActorsTools) {
    if (Tool->GetToolNameText().ToString() == TEXT("Merge")) {
        MergeActorTool = Tool;
        break;
    }
}

When accessing the registered tools, look at their names in GetToolNameText() if you need a specific one. They’re “Merge”, “Simplify”, “Batch” and “Approximate”. Then finally call it on a selection using the GEditor global:

GEditor->SelectNone(false, true, false);
GEditor->SelectActor(Actor, true, false, false, false);
MergeActorTool->RunMergeFromSelection();

That’s not how I’m planning to use it in my final code, but just having it running is a step in the right direction. Hopefully this helps whoever comes after.