PYTHON: How to Create New Struct?

I can create a new Object and get/set properties in Python like that:

my_class = unreal.load_class(None, '/MyPath/MyBp.MyBp_C')  # Loaded Class
test_obj = unreal.new_object(my_class)  # New Object
current_prop = test_obj.get_editor_property('MyIntProperty')  # Get Property
new_prop = test_obj.set_editor_property('MyIntProperty', 5)  # Set New Int Property

But How can I create a new Struct and get/set properties to it in Python? For example, I have my custom Struct BPS_MyStruct. Any help is appreciated.

If your custom struct is declared using USTRUCT macro and the properties are declared using UPROPERTY you should be able to do

test = unreal.BPS_MyStruct()

Thanks for the reply. I created Struct with Blueprints like this.

I tried as you suggested but it seems such a struct isn’t seen in Python. I tried this:
test = unreal.BPS_BEProperty()

And I got this error:
AttributeError: module ‘unreal’ has no attribute ‘BPS_BEProperty’


Also I tried loading this asset. It’s loaded fine but I cannot get/set any property(float/bool/int etc) in it.

test_asset = unreal.load_asset('/MyPath/BPS_BEProperty')
current_prop = test.get_editor_property('Float')

Error will look like this:
Exception: UserDefinedStruct: Failed to find property ‘Float’ for attribute ‘Float’ on ‘UserDefinedStruct’

But I have got this prop in the Struct:

Ah ok I though you were creating the struct in c++

Any chance you ever ended up figuring out how to instantiate a Python object from a editor defined UStruct? I have the same problem and would REALLY prefer to not have to port a bunch of structs to C++

I “solved” it like this:

I created an Object class which duplicates all parameters of a Struct. Then I put this Object as an input into a Python node. Or create this Object inside of the Python node.

It looks like a hack but it works. I have to create a wrapper Object and duplicate all parameters of a Struct. I found only this way to exclude any C++ works.