Apply or change materials on skeletal meshes with Python.

Hey there,

is there a way to apply materials to a skeletal mesh with Python?
Unfortunately it isn’t the same as for static meshes where I can set them like this:

MyStaticMesh.set_material(MaterialSlotNumber, MyMaterial)

I discovered just a material-array, that I can get from a skeletal mesh and the documentation says it is read-only.

I would be thankful for any kind of suggestions.
Thank you in advance for your help and time.

Hm, the documentation for that materials member says that it’s read only, but the documentation for the property at the top of the page under Editor Properties says it’s read-write.

What happens if you use get_editor_property(“materials”) to retrieve the array of materials, make your substitution, then call set_editor_property(“materials”, my_array) to make it use your new set?

I think the problem is, that we get a struct property and also need to set the material as a struct. The documentation may be not exact on this point. We don’t get a list of skeletal materials, we get an array of material structs. We can convert them to materialinterfaces (and use them like normal), but we can’t insert them easily back, because we need them to be in a type struct. I couldn’t found a way to convert from material to a struct right now.
Would be interested in a solution.