Can I turn on/off Animation Layer Mask from code?

Here’s the situation… I have my sword animation as a separate layer, (when i equip the sword, i set the layers weight to 1). This layer has the hips and below masked off, so that I can keep walking or running and still do a sword attack.
What I want to do is, to use leg/hip animations if i am not running. Yes, I know i can use another layer without a mask… But, Can I enable or disable animation layer mask from code?

Thank You

I as well am searching for an answer to this. I have an IK layer setup for using a rifle and positioning the hands on it using a mask to allow for my leg animations to still be used. if I disable the IK and hide the rifle his arms just hang so I need to see if there is a way to disable the mask and allow the arms to follow the animation.

Thank you

Sadly I dont see a way to perform this.

What I did was to duplicate the layer which I want to “turn off the mask”.
Afterwhich, I turn on and off the Layerweight based on what I want to happen