Apophis3d
02-27-2008, 10:05 PM
I am building a renaming script for a class project. My script works in two ways it has a manual mode for selections also an Automatic mode. I have the manual mode working fine just like it should work however the Automatic mode is proving to be quite unforgiving.
Right now I am working on making it auto rename all the lights in the scene if for some reason you wanted all the lights to be one name. Heres that script.
if ((`menuItem -q -radioButton aut` == 1) && (`menuItem -q -radioButton light` == 1))
{
//checks for lights
string $sel[] = `ls -lt`;
string $ind_obj;
//loop
for ($ind_obj in $sel)
{
rename $ind_obj $txRename;
}
}
}
Here is the rest of the code
global proc EasyName()
{
//Code written by Apophis3d(Chris Hatchie) This script provides a fast and easy way to renaming objects just select and go! Or automaticly renaming a bunch of objects quickly using the auto renaming function!!
//Checks to see if the window exists
if (`window -query -exists Ename`)
deleteUI Ename;
//Window setup
string $menu = `window -menuBar true -title "Easy Namer" Ename`;
//File Menu
menu -label "File" -tearOff true;
menuItem -label "Exit"
-command ("deleteUI -window " + $menu);
//Objects Menu
menu -label "Objects" -tearOff true;
radioMenuItemCollection;
menuItem
-label "NURBS Primitives"
-radioButton on nurbs;
menuItem
-label "Polygon Primitives"
-radioButton off poly;
menuItem
-label "Subdiv Primitives"
-radioButton off subd;
menuItem
-label "Lights"
-radioButton off light;
//Selection Mode Menu
menu -label "Selection Mode" -tearOff true;
radioMenuItemCollection;
menuItem
-label "Manual"
-radioButton on man;
menuItem
-label "Auto"
-radioButton off aut;
//Help Menu
menu -label "Help" -helpMenu true -tearOff true;
menuItem
-label "About"
-command "about1();";
rowColumnLayout
-numberOfColumns 2
-columnWidth 1 150;
//Text Field
textField -tx "Unkown"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;
}
//renaming script
global proc namehere()
{
//Querys text in the text field
string $txRename = `textField -q -tx rename_TF`;
//Querys Objects
string $mSel = `menuItem -q -radioButton poly`;
string $mSel = `menuItem -q -radioButton nurbs`;
string $mSel = `menuItem -q -radioButton subd`;
string $mSel = `menuItem -q -radioButton light`;
//Querys Selection Mode
string $mSel = `menuItem -q -radioButton man`;
string $mSel = `menuItem -q -radioButton aut`;
//statements
//checks for selection mode if manual is selected object type does not matter
if (`menuItem -q -radioButton man` == 1)
{
//checks for selected objects
string $sel[] = `ls -sl`;
string $ind_obj;
//Loop
for ($ind_obj in $sel)
{
rename $ind_obj $txRename;
}
}
if ((`menuItem -q -radioButton aut` == 1) && (`menuItem -q -radioButton light` == 1))
{
//checks for lights
string $sel[] = `ls -lt`;
string $ind_obj;
//loop
for ($ind_obj in $sel)
{
rename $ind_obj $txRename;
}
}
}
//About the program
global proc about1()
{
confirmDialog -title "About Easy Namer" -messageAlign center -message "Easy Namer v1.0 \n Created by Apophis3d (Chris Hatchie) \n Questions or Comments visit www.apophis3d.net"
-button "OK" -defaultButton "OK";
}
Right now I am working on making it auto rename all the lights in the scene if for some reason you wanted all the lights to be one name. Heres that script.
if ((`menuItem -q -radioButton aut` == 1) && (`menuItem -q -radioButton light` == 1))
{
//checks for lights
string $sel[] = `ls -lt`;
string $ind_obj;
//loop
for ($ind_obj in $sel)
{
rename $ind_obj $txRename;
}
}
}
Here is the rest of the code
global proc EasyName()
{
//Code written by Apophis3d(Chris Hatchie) This script provides a fast and easy way to renaming objects just select and go! Or automaticly renaming a bunch of objects quickly using the auto renaming function!!
//Checks to see if the window exists
if (`window -query -exists Ename`)
deleteUI Ename;
//Window setup
string $menu = `window -menuBar true -title "Easy Namer" Ename`;
//File Menu
menu -label "File" -tearOff true;
menuItem -label "Exit"
-command ("deleteUI -window " + $menu);
//Objects Menu
menu -label "Objects" -tearOff true;
radioMenuItemCollection;
menuItem
-label "NURBS Primitives"
-radioButton on nurbs;
menuItem
-label "Polygon Primitives"
-radioButton off poly;
menuItem
-label "Subdiv Primitives"
-radioButton off subd;
menuItem
-label "Lights"
-radioButton off light;
//Selection Mode Menu
menu -label "Selection Mode" -tearOff true;
radioMenuItemCollection;
menuItem
-label "Manual"
-radioButton on man;
menuItem
-label "Auto"
-radioButton off aut;
//Help Menu
menu -label "Help" -helpMenu true -tearOff true;
menuItem
-label "About"
-command "about1();";
rowColumnLayout
-numberOfColumns 2
-columnWidth 1 150;
//Text Field
textField -tx "Unkown"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;
}
//renaming script
global proc namehere()
{
//Querys text in the text field
string $txRename = `textField -q -tx rename_TF`;
//Querys Objects
string $mSel = `menuItem -q -radioButton poly`;
string $mSel = `menuItem -q -radioButton nurbs`;
string $mSel = `menuItem -q -radioButton subd`;
string $mSel = `menuItem -q -radioButton light`;
//Querys Selection Mode
string $mSel = `menuItem -q -radioButton man`;
string $mSel = `menuItem -q -radioButton aut`;
//statements
//checks for selection mode if manual is selected object type does not matter
if (`menuItem -q -radioButton man` == 1)
{
//checks for selected objects
string $sel[] = `ls -sl`;
string $ind_obj;
//Loop
for ($ind_obj in $sel)
{
rename $ind_obj $txRename;
}
}
if ((`menuItem -q -radioButton aut` == 1) && (`menuItem -q -radioButton light` == 1))
{
//checks for lights
string $sel[] = `ls -lt`;
string $ind_obj;
//loop
for ($ind_obj in $sel)
{
rename $ind_obj $txRename;
}
}
}
//About the program
global proc about1()
{
confirmDialog -title "About Easy Namer" -messageAlign center -message "Easy Namer v1.0 \n Created by Apophis3d (Chris Hatchie) \n Questions or Comments visit www.apophis3d.net"
-button "OK" -defaultButton "OK";
}
