If you want to save yourself the hassle of writing a baking animation script yourself, there's a website scriptspot with dozens of scripts that do just that.
Unless there's been a fairly dramatic change to the scripting API then it's not possible. You have no useful access to the layer stack or tools via script
i wrote a script some years back... http://www.scriptspot.com/3ds-max/scripts/powerswitcher-enanced-viewport-switching-release answered on cgsociety too
There are quite a few scripts out there that help you create reference planes. http://www.scriptspot.com/3ds-max/scripts/create-reference-planes-from-a-psd