PDA

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


Apophis3d
02-22-2008, 12: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;
radioMenuItemCollection;
menuItem
-label "NURBS Primitives"
-radioButton on;
menuItem
-label "Polygon Primitives "
-radioButton off;
menuItem
-label "Subdiv Primitives"
-radioButton off;
menuItem
-label "Lights"
-radioButton off;

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

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

rowColumnLayout
-numberOfColumns 2
-columnWidth 1 150;

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

//Renaming Button
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;

//Loop
for ($ind_obj in $sel)
{
rename $ind_obj $txRename;
}
}

meljunky
02-22-2008, 05: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.
Example:
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
www.neljunky.com (http://www.neljunky.com/)

CGTalk Moderation
02-22-2008, 05: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.