PCG with a Procedural Mesh

So I’m in the same boat here. Did y’all have any luck?

I’ve got a procedural mesh component and a PCGComponent, both created at runtime, the latter from a graph provided through a blueprint subclass.

        UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
        UProceduralMeshComponent* TerrainMesh;

        UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
	class UPCGComponent* PCGComponent;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	class UPCGGraph* Graph;

Ultimately, I create the mesh and call Generate on the component:

   TerrainMesh->CreateMeshSection_LinearColor(0, Vertices, Triangles, TArray<FVector>(), UVs, TArray<FLinearColor>(), TArray<FProcMeshTangent>(),true);
    
    if (TerrainMaterial != nullptr)
    {
        TerrainMesh->SetMaterial(0, TerrainMaterial);
    }

    PCGComponent->Generate();

Nothing happens. I’m using the previously discussed Word Ray Hit Query connected to a Surface Sampler:

The same graph generates fine when placed manually in a PCGVolume in the editor, so long as the volume overlaps a surface. I’m not sure what’s wrong here – the cast ray not hitting the mesh, the mesh not being of an appropriate type, not having an explicit volume, etc. (I’m using UE 5.5.1).

Bonus question: Assuming I had added some pins to the “Input” node of the graph so I could provide arguments, how would I populate their values from C++? Or is there another way to “pass” arguments from the C++ actor into the graph? (Most of the options in Blueprints aren’t available in PCG Graphs). Because the other option is for me to somehow get the mesh out of the UProceduralMeshComponent and pass it into the Surface sampler directly.