PDA

View Full Version : Rename multiple objects with one name...


StefanStavrev
11-20-2006, 06:57 AM
I wrote this script to rename multiple selected objects with one name plus apropriate integer.

For example i set the name to stefan , the first selected object will be stefan,the second stefan1,then stefan2,stefan3 ....

A problem eoccurs when i rename parented objects.For example, i have two cubes in my scene.One is parent and one i child.By excecuting this script they both receive stefan.
By the way i select them firts as separate objects.Here is the script :

//////////////////////////////////////////////////////

proc renameObjectsOneName() {
string $sel[] = `ls -sl`;
for($each in $sel) {
string $Text = `textField -q -text textfield1`;
rename $each $Text;
}
}

//////////////////////////////////////////////////////

You have any idea how to make it work with parented objects too ?

grantimus
11-20-2006, 10:19 AM
With the rename command, Maya does not automatically add 1,2,3 etc. to an objects name if that object already exits. In the rename command you'll have to tell it what that integer should be.

Try this:


proc renameObjectsOneName() {
string $sel[] = `ls -sl`;

for($i=0;$i<size($sel);$i++) {
string $Text = `textField -q -text textfield1`;
rename $sel[$i] ($Text + $i);
}
}


Also keep in mind that if you have the parent selected, Maya will hightlight the parent and child. However, the ls command will only return the parent. Make sure that you really do have everything selected.

CGTalk Moderation
11-20-2006, 10:19 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.