How do you change the property of a blueprint in your Content Browser from a blueprint in your scene?

I have a blueprint in my Content Browser called test6. I have another blueprint in the scene with a function exposed to the editor.

The function ChangeBPProp should be able to change a property of the test6 blueprint. My attempts keep resulting in a cast failed.

Here is my blueprint with the ChangeBPProp function

Change Property of Blueprint error posted by anonymous | blueprintUE | PasteBin For Unreal Engine

Note: In the Get Asset By Path there is only 1 bp test6 and I have verified that it is finding test6. I have also confirmed that the found class for test6 is of type AlphaBrush_BP

As you can see from the code when I cast test6 to AlphaBrush_BP the result fails. What am I doing wrong?

Generally objects need to be in the world in order to be objects. Meaning finding the object by asset really isn’t finding an object in the level. If the object(BP) was an editor utility widget, and the widget was running, your code would be fine, because there is an existing object related to the asset that is in existence. But just a normal BP inheriting from an actor lets say, is not going to be valid unless it exists in the world already.

1 Like

Are you trying to change a property on the CDO of the asset?

But it does actually find the BP in the editor. I have also tried the Load Asset function which specifically states that it loads an asset from the Content Window. Load Asset | Unreal Engine Documentation

Attached is a picture of test6 bp. I am trying to update the HeightMap property.

I tried your code. It’s as I mentioned, you essentially have an Asset Object not an instance of the Object itself (in the level). If you take the class of the object and print it you’ll see what I mean.

Try this instead - make an editor utility or editor utility widget.

1 Like

I am still getting invalid. Thanks for your help.

More info. I am getting error: ‘Alpha Brush BP’ does not inherit from ‘Blueprint’ ( Cast To AlphaBrush_BP would always fail).

This happens when I try to cast test6 to AlphaBrush_BP . test6 parent class is AlphaBrush_BP.

TY.

Can you clarify more specifically what you want to happen, when you say “change the property of a blueprint in your Content Browser”? That part doesn’t make sense, so we’re all grasping at straws trying to figure out what you want to happen.

Sure.

Here is a picture of the blueprint in my Content Window.

When I double click on it, I get properties I can change such as the Name field.

The properties are inherited from its parent class.

All I want to do is from an Editor Utility programmatically change these variables such as the Name field.

TY!

When changing properties from class CDO in blueprint I’ve only even been able to do it reliably with python or C++ directly.

1 Like

So you are correct in that I need to change the class defaults. It looks like it is very easy in python.

import unreal_engine as ue
from unreal_engine.classes import Blueprint

blueprint = ue.load_object(Blueprint, '/Game/DumbActor')

blueprint.GeneratedClass.get_cdo().ChangeMe = 17.0

print(blueprint.GeneratedClass.get_cdo().ChangeMe)

blueprint.save_package()

I just don’t understand why it is not easy to do in blueprints. I know there is a function to get class defaults, but I do not see one the allows you to set class defaults.

Do you by chance know the C++ equivalent to the python code I posted? I can’t seem to get the syntax correct in C++.

I did use python and the code below worked perfectly.


import unreal

# get the generated class
blueprint_generated = unreal.EditorAssetLibrary.load_blueprint_class("/Game/test/dan_peak.dan_peak")

# from that, get the class default object ( the actual template for the blueprint )
blueprint_class_default = unreal.get_default_object(blueprint_generated)

# set or get properties
blueprint_class_default.set_editor_property("Name", "test")
unreal.EditorAssetLibrary.save_asset("/Game/test/dan_peak.dan_peak")
1 Like