Thanks haggi for info,
I was already trying out that -beforeShowPopup in optionMenu but doesn’t seem to work in this case. It show the menus but after change material name it would still show the old name. Perhaps i am doing something wrong.
Here is the whole script (without -beforeShowPopup) Just make few objects and assign different mats to them.
if (`window -q -ex MATren`) deleteUI MATren;
string $window = `window -t "Material Rename" -tlb 1 MATren`;
columnLayout -adj true;
global string $sel[];
textField -bgc 0.22 0.22 0.22 -ed true -w 100 -h 27 -font "boldLabelFont" -cc "RnamE" -tx $sel[0] selObject;
scriptJob -parent selObject -e "SelectionChanged" UpdateProc;
separator -style "none" -h 3;
string $allSEL[] = `ls -type "lambert" -type "VRayMtl"`;
optionMenu -h 27 -cc matsASSs MATlist;
for ($oneSEL in $allSEL)
{
menuItem -label (" " + $oneSEL);
menuItem -en false ( " > " + `nodeType $oneSEL` + "
") ;
}
separator -style "none" -h 1;
showWindow MATren;
proc matsASSs(){
string $objASS[] = `ls -sl`;
if ( size($objASS) == 0 ) {
inViewMessage -amg ("<span style=\"color:#ff0038;\"> NONE </span> - objects selected!" ) -fade -pos botLeft -fontSize 9 -frameOffset 50;
}
if ( size($objASS) >= 1 ) {
string $matASS = `optionMenu -q -value MATlist`;
select -r $objASS;
hyperShade -a $matASS;
select -cl;
}
}
proc RnamE() {
string $mySels[] = `ls -sl`;
hyperShade -smn "";
string $sels = `textField -query -tx selObject`;
rename $sels;
select -r $mySels;
inViewMessage -amg ("Material - <span style=\"color:#bfff00;\"> Renamed </span>" ) -fade -pos botLeft -fontSize 9 -frameOffset 50;
}
global proc UpdateProc (){
string $obj[] = `ls -sl`;
if ( size($obj) == 0 ) { print ""; }
if ( size($obj) >= 1 ) {
string $sel[] = stringArrayRemoveDuplicates(ls("-mat",listConnections(listConnections("-type","shadingEngine",`ls -sl -o -dag -s`))));
textField -e -tx $sel[0] selObject;
}
}