Maya Script--Renaming the name of an object

Source: Internet
Author: User

The script is used to change the naming in Figure 1 to Figure 2, renaming objects in Maya with the same name to different names.

The renamed rule is: Group Name _ Original name _ ordinal

Check out the Official Handbook for Maya: http://download.autodesk.com/global/docs/maya2012/zh_cn/index.html

You can see how commands are used in the Script Editor in the following ways:

Help LS;

Edit the Mel script with the script editor that comes with Maya, and paste the script code:

1 string$ls _names[] = ' ls-tr ';//get the object name collection under outline view2 string$current _name;3  for($current _nameinch$ls _names) {4     //Print ("Name:" + $current _name+ "\ n");5     string$buffer [];6     int$numTokens = tokenize ($current _name,"|", $buffer);//Use | To display its full path when the same name is present7     if(Size ($buffer) >1) {8         //print ("Need to rename it...\n");9         string$tmp _name;Ten         string$new _name =""; One          for($tmp _nameinch$buffer) { A             //print ("Tmp_name:" + $tmp _name+ "\ n"); -$new _name = $new _name + $tmp _name +"_";//Plus Group name -         } the$new _name + ="#";//add an auto-accumulate number to it -         //print ("New name:" + $new _name+ "\ n"); -Print"Old Name:"+ $current _name+"---->new Name:"+ $new _name+"\ n"); -Rename ($current _name, $new _name);// Renaming + Clear ($buffer); -     } +}
View Code

Use the following methods:

1. Select all the code in the Mel's edit window

2. Click menu "File" in Script Editor and "Save script to Tool shelf"

3. Prompt to enter a new name

4. After confirmation, you will see a script named after the name on the current tool shelf.

Note:

Reprint must indicate the source and the author name

Blue Flash

Maya Script--Renaming the name of an object

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.