Replace Material Python Script

@UE_FlavienP Thanks, this script works. Question, please: The script won’t replace Materials for me in UE 5.4 in Nested Static Meshes (such as a railing imported from Revit), that has one or more Static Mesh Components under it in the Details Pane.

I changed the script to use “get_all_level_actors_components()” and "unreal.StaticMeshComponent - which does replace Materials on sub-Static Mesh Components. BUT, the change is not preserved even by Save All in the Editor.

Any thoughts, please, on how to replace Materials on Static Mesh Components that are part of an Actor, and make it stick, please?