How do I use SetStaticMesh and SetMaterial?

if you have a correct answer that you found yourself, usually one posts the answer for it, as this way other people with the same problem can use it.