Access C++ UStruct from Python

I have a C++ struct, that I store in an array of my own Component:

I want to edit this from a Python script. Is it possible? And if yes, how?

I had an FString type called Name and I could modify it easily:

1 Like

Any updates on this one?

Ok, solved it myself.

You can find all in Python available unreal types under <ProjectDirectory>\Intermediate\PythonStub\

In your Python editor script, you can then access these types like this

import unreal

your_custom_struct = unreal.YourCustomUStruct()

Here is how it looked for me concretely

C++ struct def

struct FMeshWithPickProbability

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Custom)
	class UStaticMesh* StaticMesh = nullptr;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Custom)
	int32 Probability = 1;

Python code

import unreal

# ...
mesh_with_pick_probability = unreal.MeshWithPickProbability(static_mesh=my_data_asset.mesh_building_block, probability=1)