Cannot Change Animator Layer Settings in Script

I finally found the solution in this thread: