Override inherited subobject (component) properties from python?

Hello.
I am creating some automation Editor Utilities for generating new blueprint assets. New blueprints are children of certain parent class which has some mesh components. I need to override default parameters for these components in my new child blueprint assets.

First I tried accessing them through default object properties, but there are no components in default objects.

Then I found a way to list all subobjects with:

subobj_ssys = unreal.get_engine_subsystem(unreal.SubobjectDataSubsystem)
all_subobjhandles = subobj_ssys.k2_gather_subobject_data_for_blueprint(asset)
for subobjhandle in all_subobjhandles:
    subobjdata = unreal.SubobjectDataBlueprintFunctionLibrary.get_data(subobjhandle)
    object = unreal.SubobjectDataBlueprintFunctionLibrary.get_object(subobjdata)
    if object.get_class() == unreal.StaticMeshComponent.static_class():    
        object.set_editor_property("StaticMesh", new_asset_mesh)

but this seems to change base class component value, not the child as the returned subobjects point to component inside base blueprint. So I guess I need to do it somehow differently!?
I feel like I need to add a new inherited subobject property override in child blueprint somehow. Any idea how to do this?

1 Like

Hi! Did you figure it out? I am also facing this problem.
My code is similar to yours, and it will edit the parent blueprint’s component, and sometimes also edit the child blueprint’s. However, if I change the parent’s blueprint to default value, the child will be influenced. I am also trying to find the correct way to set the mesh for a child blueprint’s component :/.

I figured it out. You need to use C++ UInheritableComponentHandler

1 Like