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

Hi,

this might be old news now.. but just in case anyone else stumbles upon this.

I’m doing more or less the same thing. Just in my case I want to set the SkeletalMeshAsset on a SkeletalMeshComponent of my blueprint child. I found that using the method get_object_for_blueprint() actually returns the inherited component on my child asset. And then I can set the SKM asset correctly in my child blueprint asset (and not on the parent bp).

in the above code snippet instead of

object = unreal.SubobjectDataBlueprintFunctionLibrary.get_object(subobjdata)

use

object = unreal.SubobjectDataBlueprintFunctionLibrary.get_object_for_blueprint(subobjdata, asset))

that works for me. (asset being the child blueprint)