Getting nested struct value from blueprint variables with python?

I’m attempting something similar to…le-from-python

Basically I want to copy the default values of a blueprint’s struct variable (the defaults of the struct as set in the BP defaults, not the struct definition defaults) so I can use them to change other game settings with a script.

Right now I’m trying to get the nested struct value with

blueprint = unreal.load_object(None, '/Game/Blueprints/XYZGameMode_BP.XYZGameMode_BP_C')
bp_cdo = unreal.get_default_object(blueprint)
print bp_cdo.get_editor_property("LevelData").get_editor_property("NestedValue")

But that fails with [FONT=courier new]Exception: StructBase: Failed to find property.... I can’t seem to get at the internal struct values in any way.

I should note that when I do something like “bp_cdo.get_editor_property(“StringVariable”)” the default value returns just fine.

Is what I’m trying to do possible?

If LevelData is a struct instance then that should work. How is your struct type defined?

User Defined Structs (structs defined as assets) use mangled internal names for properties, and I suspect that it would be impossible to find them from Python as things currently stand, though C++ defined structs should work just fine.

Thanks for the definitive reply, Jamie. In our case they are User Defined, but we could port them to C++ or move the data elsewhere easily :slight_smile:

Did you find a solution to this in python?

The only way worked for me is to extend python with C++.
Make sure the struct type is Blueprintable, by adding macro USTRUCT(Blueprintable). Then in my blueprint function library plugin, I defined my own C++ functions to read and write the user defined struct type variables. And finally I could access the data I wanted with Python back in editor…