PDA

View Full Version : Rename Texture Tool


xavikai
06-13-2012, 05:33 PM
Hi, I'm doing a script to rename textures but I can not directly edit texfield, anyone know how I can do? This is my code:

//Renaming Texture tool

string $RNM_Win = `window -t "Rename texture"`;
string $filePath[];
columnLayout -adj true;
string $sel[] = `ls -type "file" -long`;
for ( $i=0 ; $i < size($sel) ; $i++ ){
$filePath[$i] = `getAttr ($sel[$i] + ".ftn")`;
textFieldGrp -tx $filePath[$i] nameTxt[$i];

}

button -l "CLOSE" -c "deleteUI -window $RNM_Win";

showWindow $RNM_Win;

earlyworm
06-13-2012, 05:51 PM
Your mel script worked for me - I was able to edit the text fields. Perhaps try setting the -editable flag to true and see what happens. Like so...

string $RNM_Win = `window -t "Rename texture"`;
string $filePath[];
columnLayout -adj true;
string $sel[] = `ls -type "file" -long`;
for ( $i=0 ; $i < size($sel) ; $i++ ){
$filePath[$i] = `getAttr ($sel[$i] + ".ftn")`;
textFieldGrp -editable true -tx $filePath[$i] nameTxt[$i] ;

}
button -l "CLOSE" -c "deleteUI -window $RNM_Win";
showWindow $RNM_Win;

xavikai
06-13-2012, 09:37 PM
Hello earlyworm, the textfield is editable but not rename the textures. I want to edit the name of the texture and look to upgrade the texture with the new name.

Nyro
06-14-2012, 10:29 AM
There is no link between your textfield and the texturenode. If you want that behaviour, you have to replace the textfield with a namefield.

NaughtyNathan
06-14-2012, 11:25 AM
he doesn't want to edit the file node name, he wants to edit the file node's .ftn data to point to a different image file on disk, so a nameField would be no help here...

Nyro is correct though, normally there is no relation between your UI controls and anything else in your scene, you have to manually connect them with change callbacks. However, if you are wanting to modify specific node attributes you can use the attr equivalent of the aforementioned nameField: attrControlGrp. Something like this should work:
window;
columnLayout -adj 1;
for ($node in `ls -type "file"`)
attrControlGrp -attribute ($node + ".ftn");
showWindow;

xavikai
06-14-2012, 12:07 PM
Many thanks NaughtyNathan!!! The script works fine!

Script Rename textures and materials:

//Renaming Material Texture tool
//xavikai@gmail.com

string $RNM_Win = `window -t "Rename textures&materials!"`;
string $filePath[];
columnLayout -adj true;
string $sel[] = `ls -type "file" -long`;
for ( $i=0 ; $i < size($sel) ; $i++ ){
nameField -o ($sel[$i]);
attrControlGrp -attribute ($sel[$i] + ".ftn");
}
button -l "CLOSE" -c "deleteUI -window $RNM_Win";
showWindow $RNM_Win;
//end script

CGTalk Moderation
06-14-2012, 12:07 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.