Can you edit a Blueprint Variable from Python?

I have been digging around, but I have been unable to find anything that looks like a way to edit an Animation Blueprint directly. There are ways to create them and assign a skeleton but that is about where my editing stops.

I have a blueprint with an array of AnimSequences I need to edit the values of. Is this possible? The docs don’t seem to have anything that I can identify as a way…

I would have thought that using get_editor_property(‘variableName’) would work on a variable but to no avail.

Is it possible to list all available editor_properties? The would at least allow for easier investigation.

You can, but you need to set them on the Class Default Object (CDO) of the Blueprint Generated Class (BPGC), rather than the Blueprint asset itself (which is just a definition of how to build the BPGC). This requires the Blueprint asset itself to be compiled and up-to-date:


# get the generated class of the Blueprint (note the _C)
bp_gc = unreal.load_object(None, "/Game/MyBP.MyBP_C")
# get the Class Default Object (CDO) of the generated class
bp_cdo = unreal.get_default_object(bp_gc)
# set the default property values
bp_cdo.set_editor_property("MyFloatProp", 1.0)
bp_cdo.set_editor_property("MyBoolProp", True)

6 Likes

Thank you! I was not aware that the objects had multiple ways of being handled.

hi. The above code is to get the variables of class defaults, can I get the data at runtime? For example, I get a string of characters through an editable textbox and store it in this variable. Obtained in python.

[USER=“2003”]Jamie Dale[/USER]
Just trying your code and it looks like it’s not working:
“LogPython: Error: bp_cdo = ue.get_default_object(bp_gc)
LogPython: Error: TypeError: NativizeClass: Cannot nativize ‘Blueprint’ as ‘Class’ (allowed Class type: ‘<any>’)
LogPython: Error: TypeError: NativizeObject: Cannot nativize ‘Blueprint’ as ‘Object’ (allowed Class type: ‘Class’)”

@intoxicat3 You’re using a Blueprint rather than its generated class. My example explicitly states that you need to use the generated class.

Hi Jamie_Dale! I was trying to find exactly it!
But another question. What if the load_object is a Editor Widget Utility, I already tested and your code works to get the variables of that Widget. But I can not get the components inside, like TextBox, etc…
How can I do that ?

TypeError: NativizeClass: Cannot nativize ‘Blueprint’ as ‘Class’ (allowed Class type: ‘’)

how do you mean, generated class ?

how do you modify the actual BP asset ?

Hello!

You can use this to get the generated class:
bp_class = unreal.load_object(None, bp_ref.generated_class().get_path_name())

I also thought it was not very clear, so I made this snippet for future reference:
Call functions or modify properties of a Blueprint from Python | Epic Developer Community (epicgames.com)

4 Likes

This worked, thanks a lot!

Thank you so much!