How to compile an actor BP in python?

Hello,

Anyone know how to compile an actor BP from python ?

For the context, I modify my BP, changing the material from some skeletal meshes and it works well, but i noticed that sometimes the change is forgotten at next restart because i didn’t recompile the BP. So it seems that recompiling is necessary to commit the changes.

I have lots of BP and recompiling manually (open + click compile) kind of miss the point of modifying BP through python :slight_smile:

I couldn’t find any “compile” or “recompile” function in the api doc.
I found a “recompile_VM” but not sure what it is and i couldn’t use it anyway.

Any help welcomed :slight_smile:
Cheers
Cedric

1 Like

I’d also love to know how to do this.

Any movement on this? I would really like to compile blueprints, niagara systems, and niagara emitters. Either in python or through a BP method. Thanks

It’s easy if you are using UE5, there is a new editor bp lib: BlueprintEditorLibrary

    @classmethod
    def compile_blueprint(cls, blueprint):
        r"""
        X.compile_blueprint(blueprint) -> None
        Compiles the given blueprint.
        
        Args:
            blueprint (Blueprint): Blueprint to compile
        """
        return None

just call it:

unreal.BlueprintEditorLibrary.compile_blueprint(your_bp)

If in UE4, the “compile” function is not callable from python, but you can wrap and make it blueprint callable in your UBlueprintFunctionLibrary, just like BlueprintEditorLibrary.h did

.h

	/**
	* Compiles the given blueprint. 
	*
	* @param Blueprint	Blueprint to compile
	*/
	UFUNCTION(BlueprintCallable, Category = "Blueprint Upgrade Tools")
	static void CompileBlueprint(UBlueprint* Blueprint);

.cpp

void UBlueprintEditorLibrary::CompileBlueprint(UBlueprint* Blueprint)
{
	if (Blueprint)
	{
		// Skip saving this to avoid possible tautologies when saving and allow the user to manually save
		EBlueprintCompileOptions Flags = EBlueprintCompileOptions::SkipSave;
		FKismetEditorUtilities::CompileBlueprint(Blueprint, Flags);
	}
}

1 Like