View Full Version : Easy Rename Tool (need some help)

02 February 2008, 01:29 AM
I am currently making a renaming plugin for Maya 2008. I know it has a feature like that already built in but I like to customize my interface. Also I figured other people might like my version of the renamer better.

My tool gives the user various options for objects to rename. Poly, NURBS, Subdiv and lights. Then it gives you selection options manual selection or auto selection. I have a basic operational version of the manual mode working.

However I am having issues linking the manual mode to the manual selection menu. I only want it to work in manual mode only when manual is selected. Also it needs to check to make sure you have the right object mode selected, it should not let you manualy rename a polycube when you have NURB mode selected. Also how would I work it into my code so it will properly put a number on the end of the objects being renamed. For example myBox_01, myBox_02 and so on depending on the amount of objects being renamed? I know it has something to do with # as to where it goes in my code i am not sure textfield maybe??

Heres the code

global proc EasyName()
//Checks to see if the window exists
if (`window -query -exists Ename`)
deleteUI Ename;

//Window setup
string $menu = `window -menuBar true -title "Easy Name" Ename`;

//File Menu
menu -label "File" -tearOff true;
menuItem -label "Exit";

//Objects Menu
menu -label "Objects" -tearOff true;
-label "NURBS Primitives"
-radioButton on;
-label "Polygon Primitives "
-radioButton off;
-label "Subdiv Primitives"
-radioButton off;
-label "Lights"
-radioButton off;

//Selection Mode Menu
menu -label "Selection Mode" -tearOff true;
-label "Manual"
-radioButton on;
-label "Auto"
-radioButton off;

//Help Menu
menu -label "Help" -helpMenu true -tearOff true;
-label "About";

-numberOfColumns 2
-columnWidth 1 150;

//Text Field
textField -tx "Name me"rename_TF;

//Renaming Button
-label "Rename Object"
-command "namehere();";

showWindow $menu;

//Edits Window
window -edit -widthHeight 283 90 $menu;
window -edit -tlc 180 50 $menu;

global proc namehere ()
//Querys text in the text field
string $txRename = `textField -q -tx rename_TF`;

//checks for selected objects
string $sel[] = `ls -sl`;
string $ind_obj;

for ($ind_obj in $sel)
rename $ind_obj $txRename;

02 February 2008, 06:51 PM
You need to query each object to determine the node type. In order to do that you first must know the shape node.
nodeType pSphere1;
// Result: transform //
nodeType pSphereShape1;
// Result: mesh //

Here is a sample command to determine the children:
nodeType `listRelatives -s pSphere1`;

As for the # in the rename command the help docs mentions:
If the new name ends in a single '#' then the rename command will replace the trailing '#' with a number that ensures the new name is unique.

Does not allow for padding that would have to be done manually.

I have a renaming script that does auto padding on my web site, you can check it out there, line 381.

I dont have time to extract the code as a stand alone.

One last thing when people say plugin that generally refers to the API

Hope that helps,
Brian (

CGTalk Moderation
02 February 2008, 06:51 PM
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.