Maya has a built in re-naming tool, Rename Selected Objects, on the right side of the Status Line. Select Rename from the menu of line input operations, to the left of the input box.

—
Basic rename script using Python:
#rename selected Maya nodes. Adds 4 digit padding to numbered name.
import maya.cmds as mc
mySel = mc.ls(sl=True)
count = 0
for obj in mySel:
count +=1
#customize name below
mc.rename( obj, 'myObj2_' + str('%04d' % count))
—
Below are various methods to rename using MEL:
Simple approach
int $i;
//Select the object(s) that you want to rename
string $rename[] = `ls -sl`;
int $selSize = `size $rename`;
for ($i =0; $i <$selSize ; $i++){
//Change newName_, below, to the name that you want to replace.
rename ($rename[$i]) ("newName_" + ($i +1));
}
Search and replace.
Designed to find and replace part of the name of similarly named nodes.
searchReplaceNames "myNode" "newNode" "selected";
This will change names in a selection. For example you can change 100 selected nodes names from “myNode000 – myNode100″ to “newNode000 – etc”. You can replace “selected” with “hierarchy” to rename all of the nodes in a selected hierarchy, or “all” to rename all nodes in the scene.
Search and replace 2
string $search = "myNode";
string $replace = "newNode";
string $Objs[] = `ls -sl`;
for($obj in $Objs)
{
if(`startsWith $obj $search`)
{
rename $obj (`substitute $search $obj $replace`);
}
}
Rename and add custom number
//by
pappapierre
//catch the object(s) current names, and clear your selection
string $sel[] = `ls -sl`;
select -cl;
//declare a string variable which will become your new name prefix
string $newNamePrefix = "myNewName";
//now run a loop to rename each elemnt in your selection list in the order
//they were selected
for($i=0 ; $i<size($sel); $i++){
//and rename your objects accordingly
rename $sel[$i] ($newNamePrefix + ($i+1));
}
//you can start your numbers anywhere by replacing the "1" in ($i+1) with
//your desired starting number.
Rename shape nodes:
//script 1. rename shapes unique names
string $rename[] = `ls -sl -dag -shapes`;
for ($i = 0; $i<size ($rename); $i++) {
rename($rename[$i]) ("myNewShapeName_" + ($i +1));
}
//script 2. remnameShapes (all the same name)
for ($i in `ls -sl -dag -shapes`) {
rename $i "myShape";
}
//script 3. rename types
for ($i in `ls -sl -dag -type “nCloth”`) {
rename $i "myShape";
November 19th, 2009 | Posted in "code, MEL, python" | by Oliver | No Comments
Using the channel box or the attribute spreadsheet are good ways to manually change attributes on multiple selected objects.
In MEL, this script is set up to change attributes on selected nodes in the scene.
string $mySel[] = `ls-sl`;
string $name;
int $arraySize = `size $mySel`;
for ($i = 0; $i < $arraySize; $i++) { $name = $mySel[$i];
$myNode = ($name + ".rotateX");
setAttr $myNode 100; }
If you want to make changes to the shape node, you will want to use ls -sl -dag -leaf:
string $mySel[] = `ls -sl -dag -leaf`;
for ($each in $mySel)
{
setAttr ($each +".attribute") 1;
}
print $mySel;
November 4th, 2009 | Posted in "code, MEL" | by Oliver | No Comments
$x = "bob";
switch ($x)
{
case "bob":
print ("Hi Bob");
break;
case "tom":
print ("Hi Tom");
break;
default:
print ("Who's that?");
break;
}
November 3rd, 2009 | Posted in "code, MEL, tips" | by Oliver | No Comments
Command + forward slash (apple), or control + forward slash will bring selected footage items into an open composition.
Command + option + forward slash (apple), or control + alt + forward slash will replace selected footage in the timeline with selected footage from the project panel.
Hit the asterisk key on the numeric keypad to add a layer marker to a selected layer at the current point in time.
Command/control + Y creates a new solid. Command/control + shift + Y opens solid settings.
Press the u key to reveal all key frames. Press uu to reveal all modified parameters.
To match the work area to a layer’s duration: select the layer, then type “ibon“. i sends the time indicator to the in point of the layer, b sends the in point of the work area to match the time indicator. o sends the time indicator to the outpoint of the layer, n sends the out point of the work area to the outpoint of the time indicator. Better yet use command+option+b to match the work area to the duration of all selected layers.
Use the bracket [] keys to move layers in/out to the time indicator. Option+bracket will crop the in/out points to the time indicator.
To go to the first or last frame of the work area, press Shift+Home or Shift+End.
Show only properties with keyframes or expressions: Press U
After Effects Keyboard Shortcuts
November 3rd, 2009 | Posted in "After Effects, motion graphics, tips" | by Oliver | No Comments