Generating control rig blueprint graphs in C++

I’m interested in procedurally generating a control rig blueprint from my own file format, but I’m stuck on the process of attaching a custom UControlRigGraph to my blueprint.

My UControlRigBlueprint is being generated by a standard UFactory:

    virtual UObject* FactoryCreateNew(...) override



        UControlRigBlueprint* ControlRigBlueprint = CastChecked<UControlRigBlueprint>(FKismetEditorUtilities::CreateBlueprint(ParentClass, InParent, Name, BTYPE_Normal, UControlRigBlueprint::StaticClass(), CallingContext;

        UControlRigGraph* RigGraph = NewObject<UControlRigGraph>();

        // Populate the graph with nodes, e.g.

        // RigGraph->AddNode(NewNode);


        // then somehow attach the RigGraph to the blueprint


        // profit!

        return ControlRigBlueprint;


There are methods to get existing rig graphs from a blueprint:

TArray<UEdGraph*> Graphs;


but when I first create the blueprint it’s treated as data only and thus has no embedded graphs.

So my question is: can I generate a control rig graph myself and attach it to a control rig blueprint?

1 Like

This turned out to be easier than expected, URigVMController is the way to go for modifying a graph.

1 Like

A usage example to make things clearer:

URigVMController* Controller = ControlRigBlueprint->Controller;
Controller->AddStructNodeFromStructPath("/Script/ControlRig.RigUnit_BeginExecution", "Execute");
1 Like