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
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
try this script: http://www.scriptspot.com/3ds-max/scripts/detriangulator hoefully it will clean your mesh to the extent that you can select the edgeloop