// getTexture.mel // Version 1.0 // Date: 06.02.06 // Author: Volker Heisterberg // WhatIsThis: Another simple script to speed up your workflow! // Usage: Select an object in maya. Running getTexture from the command line // will select the texture of the assigned shader for your convenience. // ToDo: Error checking still incomplete! global proc getTexture() { string $selection[] = `ls -sl`; int $count = size($selection); print $count; if ($count<1) error ("Nothing was selected!"); string $shapes[] = `listRelatives -s $selection[0]`; string $sg[] = `connectionInfo -dfs ($shapes[0] + ".instObjGroups[0]")`; string $tokens[]; tokenize $sg[0] "." $tokens; string $shaderPlug = `connectionInfo -sfd ($tokens[0] + ".surfaceShader")`; tokenize $shaderPlug "." $tokens; string $shader = $tokens[0]; string $texturePlug = `connectionInfo -sfd ($shader + ".color")`; tokenize $texturePlug "." $tokens; string $texture = $tokens[0]; //print $texture; select -r $texture; }