Apply materials to a Geometry Cache in scripted action

Hi

I’m trying to make a blutility that will apply an array of materials to an .abc import, Geometric Cache’s material slots one after the other. This is to save time and apply the imported character’s materials all at once.

I’ve managed to make a simple version that can work for a static mesh using a material array (blueprint in .png).
However I can’t seem to find an equivalent “Set Material” Function for a Geometry Cache’s material slots. Thanks in advance you have any info on how to ge this working.

1 Like

I too am trying to do this with Python. the material slot names come up as an empty list. Here is an example of what I’m trying to do. Maybe I’ll try what @Lcraq01 is doing and cast to a Static mesh first.

geom_cache_list = []
target_content = unreal.EditorAssetLibrary.list_assets("/Game/HR/Seq/Cloth/")
for each in target_content:     
    asset_data = unreal.EditorAssetLibrary.find_asset_data(each)

    asset_class = asset_data.get_editor_property('asset_class')
    if asset_class == "GeometryCache":
        geom_cache_list.append(each)

for item in geom_cache_list:    
    geom_cache = unreal.load_asset(item)
    gc_component = unreal.GeometryCacheComponent()
    gc_component.set_geometry_cache(geom_cache)
    msn = gc_component.get_material_slot_names()
    print(f"msn: {msn}")
    # result []