Try this one, it should do the trick. Copy past to your MEL editor middel drag to your shelf. string $sel[]; int $temp[]; int $value; $sel = `ls -sl -dag -ap -typ surfaceShape`; for ($obj in $sel){ $temp = `displaySurface -q -xRay $obj`; $value = $temp[0]; if ($value == 1) displaySurface -xRay 0 $obj; else displaySurface -xRay 1 $obj; }