"-wf" flag of "getPanel" command will show you the panel that currently has focus.
In case with me, I usually use it as follows...
{
string $curPanel = getPanel -wf
;
if(modelEditor -q -xray $curPanel
)modelEditor -e -xray 0 $curPanel;
else modelEditor -e -xray 1 $curPanel;
}
*Maya 4.5 NT ~takigawa